Jump to content
Pop Smoke

Random numbers in the control logic section

Recommended Posts

I am not entirely certain how to understand the random number generator.

It's format in the box seems to be: number ( ) <= Random Variable (New, X1 etc) < ( )

So I type in for example 75 New 100

what does this mean? is there a 75% chance of the action happening or a 25% chance?

I think I am right that the NEW means that if multiple units are using the check it can throw up a different answer each time. But I'm not certain even on that.

I would like a text version of just what the symbols are saying, first number then the <= does that apply to the first number or the random number (I assume it actually means "s less than or equal too")

NEW I pretty much got that, but X1,X2 etc, is that a multiplication function or the number of times it will be applied?

And the final < I am ssuming means that the resultant number generated is less than the number you enter in the box. Using 100 seems in some instances to make it a percentage chance. what other numbers would be used, must the right hand box alway have a lower number than the left?

I am sure that for some this stuff is pretty straight forward, but it's never been my strong point :)

I have checked out the manual and the scenario design site, but neither really cover this little box in any detail.

Share this post


Link to post
Share on other sites

AFAIR, the X1 etc are set-once variables, and the value stored in each can be used for multiple tests throughout the scenario. Within a single session the same Condition will evaluate consistently on multiple tests.

'New' is an 'at-test-time' random number, and the same Condition may evaluate differently at each test.

0<=X1<75 is a 75% chance of success over a range of test-runs.

0<=X2<25 is a 25% chance of this level of success.

25<=X2<75 is a 50% chance of this level of success.

75<=X2<100 is a 25% chance of this level of success.

Share this post


Link to post
Share on other sites

Thanks for that GH, it helps a little, though I still don't understand what the fomulae is actually saying. I need simpleton type explanations. :(

Share this post


Link to post
Share on other sites

The game generates 63 random numbers when a scenario is started. It can also generate random numbers when called to evaluate conditions or events. The random numbers can be used to control behavior of computer units.

Example: "0 <= random variable X23 < 25"

This means that if the 23d of the 63 automatically generated random numbers has a value between zero and twenty-four, then that statement is true.

Using the pre-generated random numbers allows co-ordinated behavior amongst computer controlled units. For example, if you want the computer controlled units to randomly take one of three initial courses of action, you might try having three routes from each units' initial position (one for each course of action). The first course of action route for all units would have an 'embark if' condition of "0 <= random variable X1 < 35", the second would have "35 <= random variable X1 < 70", the third "70 <= random variable X1 < 100".

Share this post


Link to post
Share on other sites

Here are two example for you. In the first one, the unit in question will spawn if the variable "X1" is between 0 and 100. Since X1 will be a number between 0 and 100, this unit will always spawn.

In the second example, the unit will spawn if X1 is between 0 and 50. This will give the unit a 50% chance of spawning. The formula could also have chosen a number between 50 and 100, which would also give it a 50% chance of spawning.

If you have questions about what will happen with a give formula, just post a screen shot of the inputs/selections and we'll try to decipher the result for you.

Ex1.jpg.9a982476ed1705b9092946a62ab3da86

Ex2.jpg.6e4828b6f9a5a39a59e6d647fb672b10

Ex1.jpg.9a982476ed1705b9092946a62ab3da86

Ex2.jpg.6e4828b6f9a5a39a59e6d647fb672b10

Share this post


Link to post
Share on other sites

Right, thanks loads to Gary and Tacbat (and GH of course!) I got all that no problem, in fact I have used all those examples to the fullest extent in my latest scenario (which alas is now on hold after 6 days work due to what seems to be a Bug, see the other thread!)

So, just to make thing really clear. If I set a "spawn if" condition of 0 <= X1 <35 for a single unit, does this mean it has a 35% chance of spawning or have I misunderstood some aspect in this instance. For this to be true I assume the random number generated is always between 1 and 100, true?

Share this post


Link to post
Share on other sites

Yeah, you've got it.

To make things a bit more fun though:

Say you want to spawn a tank platoon in one of three separate locations. You could do that by putting down three tank platoons and giving them spawn if conditions using the same X-variable with ranges corresponding to 0 - 35, 35 - 70, 70 -100, or whatever. That way a tank platoon will definately spawn, it's just a question of where.

Now suppose you want to have a tank platoon and a PC platoon spawn, independently of each other, in one of three locations. You could do the same thing with PC platoons, but just use a different X-variable.

Share this post


Link to post
Share on other sites

Nice one, actually in this instance I want the platoon to spawn sometimes but not others, the Idea being that the scenario is very re-playable due to the extreme diversity, no matter how often you do this one, it will never be the same in every aspect.

Cheers Gary!

Share this post


Link to post
Share on other sites

Actually a better use is to always spawn the unit and route it to one of three positions using move to end if and the random condition.

Share this post


Link to post
Share on other sites

Nice, but there are still a couple of points here.

Over the page I posed a question:

"So, just to make thing really clear. If I set a "spawn if" condition of 0 <= X1 <35 for a single unit, does this mean it has a 35% chance of spawning or have I misunderstood some aspect in this instance"

I think Gary said yes to this.

On the SBWiki page a similar line is presented

35 <= X2 <= 100 ... the likelihood for this condition to be true is 65% (100-35=65).

There seems to be a some doubt.

Also, in the event of using 0, 35 and 70 - 100 to give three random choices (one might imagine three equally likely events), if the numbers effect the percentage in that way then one of them is going to be the most frequently activated by virtue it having a higher percent chance of occuring. No?

Apologies if I seem to continue to batter this, but a full understanding is better than a half baked notion :)

Share this post


Link to post
Share on other sites

The left figure is the lowest value that allows the condition to evaluate 'true', the right figure is the highest value that allows the condition to evaluate 'true'

From the dialogue box image above^ the lower value is inclusive, the upper value exclusive.

The chance of X1 evaluating true or false over many scenarios runs depends on the range between the two figures. The same test will always evaluate the same within the same scenario run.

The chance of 'new' evaluating 'true' or 'false' is the same as for a named variable, but subsequent uses of the same test may evaluate differently even in the same scenario run.

Think of it being like rolling % dice and writing down the values for each named variable, but rolling each time the 'new' value is called for.

From your examples:

0<=x1<100 will always be true.

0<=x1<70 will evaluate true 70% of the time

0<=x1<35 will evaluate true 35% of the time

If you are dealing with 3 seperate units or three seperate 'events' on a route, then this may be what you want...

But it is more likely for a single unit and single event that you want:

0<=x1<35 evaluates true 35% of the time

35<=x1<70 evaluates true 35% of the time

70<=x1<100 evaluates true 30% of the time

You might also want to consider using non-contigious ranges linked with {or} to allow for the use of fewer 'variables' to randomise eg route selection, allowing more for other nefarious purposes elsewhere if you find that you run short.

0<=x1<10 {or} 65<=x1<80 {or} 90<=x1<100 (35%)

20<=x1<30 {or} 35<=x1<60 {or} 80<=x1<85 (35%)

10<=x1<20 {or} 30<=x1<35 {or} 85<=x1<90 (30%)

Share this post


Link to post
Share on other sites

That's certainly cleared it up nicely for me, thanks loads GH, I do have a better understanding now. Not to the point I could explain it particularly well, but definately to the point of being able to make fuller use of it, which is more likely anyway.

Thanks to all contributors! :)

Share this post


Link to post
Share on other sites

I think that it is also worthwhile to mention that if you set up an event to occur such as 0<=x1<70 , there is a CHANCE that it will be true 70% of the time. This doesn't mean that if you were to run the scenario 10 times that the event will occur seven times. It could happen all 10 times, or not at all.

Share this post


Link to post
Share on other sites

If you leave the "x" random number as "New", will this generate a new random number and not assign it to 1 of the 63x possibes for the duration of the scenerio?

I hope thats a clear question...

Share this post


Link to post
Share on other sites
If you leave the "x" random number as "New", will this generate a new random number and not assign it to 1 of the 63x possibes for the duration of the scenerio?

I hope thats a clear question...

Yes.

I hope that's a clear answer. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...