Need help with randomizing algorithm

I already understood how to make algorithm that will randomly select event

*rand x 1 4
	*if (x = 1)
		*goto conf1
	*if (x = 2)
		*goto conf2
	*if (x = 3)
		*goto conf3
	*if (x = 4)
		*goto conf4

But I can’t inderastand how to make exclusion or ban for random event that just already used.
I wish to make series of random event that mustn’t repeat itself. Series like 1 3 2 4 or 4 2 1 3, but not like 1 1 2 3.

1 Like

If it’s not important that it be perfectly random, the easy way is to add a check if one scenario gets run, and if it has, just add one. So:

*rand foo 1 4
  *if foo = 1
    *label foo_1
    *if foo_1_has_run
      *goto foo_2
    *else
      *goto conf1
  *if foo = 2
    *label foo_2
    *if foo_2_has_run
      *goto foo_3
    *else
      *goto conf2
...

If it has to be perfectly even chances each time, it gets a little more complex.

A little more complex - but how exactly? )

Would this work, Reaperoa?

*label randomstart
*rand foo 1 4
  *if foo = 1
    *label foo_1
    *if foo_1_has_run
      *goto randomstart
    *else
      *goto conf1
  *if foo = 2
    *label foo_2
    *if foo_2_has_run
      *goto randomstart
    *else
      *goto conf2

As above Reaperoa’s would work, but if you want something ready-baked, I think this is almost exactly what you’re after?

You could just replace the “Scene X” text with a *gosub_scene command of your choosing.
As long as you then *return from that scene (not *goto_scene), your *temp variables will still be in effect, so you could use it as a sort of randomized ‘switchboard’ scene.

Running Example: http://tinyurl.com/o2f9j9o

This is exactly what I want - tnx! ))) Why this stuff don’t place in official site, in the tutorial pages?

Great. It’s not on the official site because it isn’t official (i.e. wrote by COG), but that wiki is just as valuable of a CS resource, definitely worth a bookmark!