This article has been sitting on my website for a while probably not being read much, so I thought I'd put it on here. It's aimed at people who don't really know much about creating random numbers at all, and is therefore quite basic. Any requests/corrections/suggestions regarding the formula list at the bottom are appreciated.

---

Random numbers can be very useful things when making a game, so what follows is a short explanation of how to create them in The Games Factory and Multimedia Fusion. Although it may be a long explanation, since at this point I don't know because I haven't written it yet. Here goes, anyway...



The Random( ) Function:

Your starting point in the amazing world of randomness will always be the Random( ) function. In its most basic form, you will put something like Random(6) into the Expression Evaluator, in order to generate a simple random number.
Contrary to popular belief, although I have conducted no extensive survey to prove that this is, in fact, popular belief, the 6 in Random(6) actually controls how many possible numbers could be produced, not what those numbers will be. So Random(6) will produce one of six numbers, and since you haven't said anything else about what those numbers will be, it starts from zero and works upwards. Therefore Random(6) returns 0, 1, 2, 3, 4 or 5 (6 numbers, see, even though none of them is 6).

The Random( ) function acts like any other kind of number in the Expression Evaluator, so you can add to it, divide by it, subtract from it and generally get to know it very well. Subsequently if you set a counter to Random(6) + 20, it'll first return the random number itself and then carry on as normal. So if the random number were 5 then the final output would be 25. This means you can easily generate a number within a certain range, by using this formula:

Random( Maximum - Minimum ) + Minimum

...Where Maximum and Minimum are obviously the largest and smallest numbers in the range you want. Note that if you want the possible output values to include both the maximum
and minimum values, then you need to use:

Random( Maximum - Minimum + 1 ) + Minimum


Further uses:

By cunning manipulation of the Random( ) function, you can create many different effects. Below, I'll make a list of different formulae that you may find useful in various situations.

Random positioning:
Setting something to a random position in the playfield is easy, just say:

Set X position to: Random( Frame width )
Set Y position to: Random( Frame height )


Grid positioning:
If you want to set something to a random position within a grid-based environment (useful in a snake game, for example), then put:

Set X position to: Random( Frame width / grid width ) * grid width
Set Y position to: Random( Frame height / grid height ) * grid height

Positive or negative:
In a custom movement you may want to give something a random direction by making a value either positive or negative. Try this:

1 - (Random(2)*2)
(returns either 1 or -1)

Odd or even:
Perhaps you need a random number that must be either odd or even, within a certain
range. This should work:

Random((Max - Min)/2)*2 + Min
(returns odd or even depening on whether max and min are odd or even)

Two ranges:
If there are two possible ranges you want a value to be in (that are both the same size), then you can tell it to select a range at random and then return a random value within that range like this:

Range_start + Random( Range ) + Random(2) * Range_diff
(Where Range_start is the lowest value in the first range, Range is the size of each range, and Range_diff is the difference between the lowest values of the two ranges.)

Obviously this list is by no means exhaustive, and I may add to it if I think
of any more uses.

Conclusion:

Hopefully you now understand how to make random numbers slightly better than before you started reading, although I suspect the only guaranteed benefit will have been to insomniacs.
I suppose this wasn't that short an explanation after all, although it wasn't really too long either. About medium length, I'd call it. Maybe somewhere between short and medium even, although this pointless bit at the end isn't
helping much. Perhaps I'm just trying to be extra random so as to suit the general theme. Perhaps. Who knows?