Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Randomize Seed: Same Results On Different Computers? Try And See!

Author
Message
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 30th Nov 2010 15:06
i have been wondering, for the sake of "procedural content generation",
if i use a specific 'seed' in my 'randomize' ,
will it produce the same results on my PC as on my laptop?

well, if i had a laptop, i would run it myself. but...
i wrote a very short program, and am asking dbp users to compile it
and send me their results.



perhaps, also, how often do you play a game on one computer, and then transfer your saves to another machine, and resume that game?
- basically, a 'relevancy' question...

thanks

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Nov 2010 15:18 Edited at: 30th Nov 2010 15:21
I'm guessing off the top of my head it will, but I will give it a go anyway to make sure. In answer to do I grab save games from one system to another?, the answer is mostly no, but occasionally yes, lol.
Yes, I get exactly the same results, but no surprise as you gave them the same seed. Still always nice to test out on as many machines as possible. I assume this is what you wanted and good news lol.

http://s6.bitefight.org/c.php?uid=103081
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Nov 2010 15:19
Yup, haven't tested but it will definitely produce the same 'random' numbers when you use a seed. I sometimes, rarely transfer save game files - most recently that was between the Mac and PC, for Minecraft. For complex RPG games, then being able to easily transfer save files would be handy I think.

Health, Ammo, and bacon and eggs!
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Nov 2010 15:30
I am interested in why you want to use a set seed as it sort of defeats the point of random generation does it not? I mean if every system generates the same random numbers how is it random? Would you not be better using a proper random seed and saving that data into an array or file? You should still be able to transfer save data to and from different versions(same game, diff machines) of the game just as easily.
You may have a reason for it, but I'm not quite sure what Just interested.

http://s6.bitefight.org/c.php?uid=103081
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Nov 2010 15:38
I use a specific 'seed' for creating hashed savedata etc. It's a handy thing to know.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Nov 2010 15:57
Oh, you mean more for a registration key or protection thing, rather than a save game file? It would make more sense in that case.

http://s6.bitefight.org/c.php?uid=103081
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Nov 2010 16:00
Quote: "Oh, you mean more for a registration key or protection thing, rather than a save game file? It would make more sense in that case."

Both actually. When I don't want people cheating their scores... but yes I used that as part of my license system for "Odd Blox".

Indicium
15
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 30th Nov 2010 16:13
Quote: "I am interested in why you want to use a set seed as it sort of defeats the point of random generation does it not?"


Minecraft for example uses a seed to generate it's worlds, and instead of saving every single block, it saves the seed so it can be generated again. I know from the game design forum that IBOL wants to make a similar system in an rts game.

Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 30th Nov 2010 16:51
It has to produce the same numbers every time on every computer otherwise it's useless as a method of encryption.... piking a seed then randomly making an encryption key to encrypt/decrypt.

I get the same results running the code.

IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 30th Nov 2010 18:11
thanks everyone for trying it.
i'm actually quite surprised that it yields the same results for everyone...but glad.
a few more testers wouldn't hurt.

here's the reason i want to check this out:


DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Nov 2010 19:10
oh lol, sounds similar to my current project. Although I haven't got round to the random bit yet just concentrating on getting the engine running so far.

http://s6.bitefight.org/c.php?uid=103081
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 28th Mar 2011 15:58
At a simplistic level, Random number generation is done from a fixed list, and is really called pseudo random number generation.

Most machines these days use the same 'list' so you should find you're ok accross different computers.

Be aware that different architectures and different OS may use a slightly different list and algorithms for picking numbers from that list, but if you only target windows x86 you should be fine.

The seed cause the generator to start at a specific point in the list, therefore if you randomize to the seed before starting generating random numbers for your level, you gain the ability to regenerate that level exactly the same every time you run your code.

It's not my fault!
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 28th Mar 2011 20:09 Edited at: 28th Mar 2011 20:13
I remember, back in the day, that Dungeon Hack generated a seed value from your dungeon options that was used to randomize the dungeon, and you could give the seed to a friend so they could play the same dungeon. That was kind of cool.



Attachments

Login to view attachments
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 29th Mar 2011 02:24
I DON'T think it definitely gives the same numbers given the same seed.

If you want the same results over different computer architectures, I think you should use your own pseudo-random number generator. I've heard that what's called "Mersenne Prime Twister"
And... How nice! it looks like wikipedia has some pseudo code:


OFC the wikipedia article makes it sound very complicated... but wikipedia can make anything sound complicated. It's a horrible resource for math information, unless you're a math major. Anyways... that algorithm is probably what you should use.

IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 29th Mar 2011 17:04
hey, Neuro Fuzzy ,
thanks, and in fact it was ideas like that that started me thinking along these lines.
i was thinking of creating my own random number generator.

but did you actually run the code? i'd appreciate it if you did, and posted your results here.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Mar 2011 19:28
Looking at the DBPro source code for the RND function, I see it uses the very basic Microsoft 'rand' implementation, and as that particular plug-in is compiled using the static runtime, that guarantees that the generator will generate exactly the same sequence of numbers each and every time.

That will be the case until:
1. Microsoft change their implementation, or
2. Lee changes his method of using that or chooses another implementation to use.

If you want a different random number generator, then check out the ones provided by my plug-ins - there are quite a few available: http://www.matrix1.demon.co.uk/Matrix1Utils_Help/Matrix1Util_08_index.html. These are all wrappers around the boost library generators, so they are pretty much guaranteed to be correct.

IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 30th Mar 2011 05:01
thanks for the 'definitive' answer, ianm,
i actually *want* the same results from the same seeds on different machines.

it makes it possible to generate an entire galaxy from a single number, and not have to store every planet, etc. just the seed.

SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 30th Mar 2011 05:10
Quote: "it makes it possible to generate an entire galaxy from a single number, and not have to store every planet, etc. just the seed."


So you have to regenerate it each time?


My software never has bugs, it just develops random features.
C4: silly putty for men.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Mar 2011 14:42
There's virtually no difference though, whether you store the galaxy as a file and load it in, or generate it randomly. You still have to build the galaxy, texture planet models etc etc... so the best saving is on disk space.

Imagine if you had a terrain that was generated randomly every time, instead of saving the terrain data. Really a standard for a terrain these days might be 1024x1024, which would take up 4mb of disk space. But the main thing with all of this is whether to actually do it that way or not. A human will always have trouble generating landscape after landscape, placing countless objects... it's a project killer to have a wad of work like that just waiting for someone to do. Even messing around with the files can be a drag. I personally would not consider designing terrain from scratch, I'd always generate the terrain then adjust it to suit my needs.

One other option is to use control data, rather than just a seed, which is usually a random number anyway. Imagine your terrain has 16 poles, from corner to corner laid out on a 4x4 grid. 16 heights would be stored, which is not a lot of data at all. Then once these heights are stored, the terrain could be generated, based on those initial poles, using perlin noise algo's. One benefit in that is you have some control over the makeup of the terrain with those poles - you could set the terrain to be an island, have side walls, or even use a master heightmap, where each 4x4 section of pixels is a terrain seed. That might be a good way to make an epic sized terrain. If each tile on your terrain is 1m squared, then you use a 256x256 heightmap to feed perlin 'poles' on terrains at say, 256x256, then you would have a terrain that stretches for 4million tiles, or over 3000 miles across, or almost 7 million square miles. All for the cost of a 256x256 heightmap.

We don't have big teams of level editors to do the grind work, we have to look at other options like procedural techniques, because nobody has the time to model too many terrains. I have a project that uses a big terrain, and with the automatic generation, well they look better than what I could come up with, but the project is fun to work on, because if I get sick of the terrain, I just change the seed - I don't have to model for 6 hours.

Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2024-04-30 21:04:27
Your offset time is: 2024-04-30 21:04:27