Multiplatform Random Number Consistancy

BlitzMax Forums/BlitzMax Programming/Multiplatform Random Number Consistancy

I was playing with a routine recently to bounce some objects around the screen and of course, to intialize their positions I just do a loop with random numbers for X and Y. Thing is, I later noticed that with a small number of objects they all seemed to start out in the same place every time. Then I figured it must be because the seed number stays the same unless I change it - even accross multiple compiles!

From what I gather of what the original question is asking, I was thinking the same kinda thing. See, if you want to have a random level generator in a game, let's say it puts walls in random positions or adds powerups in random locations, etc, there might be some reason why you want to then later `keep` the way that level was set up so you can come back to it if it happened to be a good one. If you knew what seed the random numbers were based on you could have it then re-generate the same results later on using that same seed number. Then you could for example just save the seed number to refer to the layout of the level. In a lot of games you may want to have the player go back to a previously created `level` to replay it (although that slightly goes against the purpose of making levels randomly, it might be a good part of the game structure).

Also yes, there are no truly random numbers in computers unless maybe you figure in some real-world input such as the time of day or whatever, which is likely to be at least slightly different each time. All numbers generated based on that seed are then different. Of course, you could have multiple re-seeding (hairline?) in the program to really produce a lot of variations.

For me, I will be creating random levels where just about everything in the level is computer-generated, but I also want to include in the game some `pre-made` levels which happen to be good ones (after all, some random results are better than others unless you specifically add in some sophisticated template or guidance) ... and I want to use the same random-level generator to generate the levels for me so that I don't have to take 50 years making a level. I can just generate a level, decide if it's a good one, and move onto the next one, keeping if it gets past my keen eye. Then it can be regenerated the same later on without having to store and load lots of level data etc. I'm sure this guy is trying to do something similar.

As for cross platform compatibility, I really don't know what algorithm they use. Maybe if you want to be sure, look on the web or something and find a random-number generator program and use it in your game to make your own randon numbers, then you have full control of the process.