• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

random seed with deterministic lock step ish

Pfap

Member
I'm wondering if anybody has any input on how to handle this, or if I'm way off with my thinking here.


If I have a script that generates random values and then if I get a random seed and send that seed to another player on a different device will they generate the same values?

Assuming players are on the same platform, lets say ios would different devices produce different outcomes from the same seeds?

I'm generating stuff on one client that needs to be represented on a different client and I am trying to avoid having to send everything and was thinking I could just send the seed and then have the other players client generate the same state as that of the opponent.
 
F

FuRyvok

Guest
If you make a game with a seed generation, every device will make the same generation with that seed.
 

Pfap

Member
Yes, I'm just not too sure on how a random seed works and this line from the docs has me concerned.
While this seed will give consistent results on each target platform, results may vary between platforms due to the different way each target works.
If I picked the seed out and sent that over would I still have an issue? For instance a client on an iPhone 6, generates the seed and then that is sent to a client on an iPhone 8 if I then set that clients seed would they generate the same "randomness"?

Another thing I was thinking about doing is having the server generate the seed...
Could I have the server generate a seed and then use random_set_seed(value_from_server)? Would this work on cross platform also?
 

TheouAegis

Member
well if you have everybody play Don McIntosh, or everybody playing on Windows, or possibly everybody playing on Android, but not a mix of the three, that it should work fine. typically, Windows is consistent with Windows, McIntosh is consistent with McIntosh, Android is consistent with Android, iOS is consistent with our last, and HTML is consistent with HTML
 

Pfap

Member
well if you have everybody play Don McIntosh, or everybody playing on Windows, or possibly everybody playing on Android, but not a mix of the three, that it should work fine. typically, Windows is consistent with Windows, McIntosh is consistent with McIntosh, Android is consistent with Android, iOS is consistent with our last, and HTML is consistent with HTML
Yea, I'm trying to avoid having to setup separate servers for each platform. But, I suppose it would probably be the thing to do, otherwise I could always just send state every time it changes on a client. I guess I'm kind of hesitant to use it because I don't understand why random would be different from system to system? Maybe I could code my own "randomizer" in gml that suits my purposes? I have 16 or so cards that need to be shuffled.
 
L

Lonewolff

Guest
Differences in machine architecture, overflow handling, and implementation differences for both the algorithm being used and the language it was being implemented in meant that results could and will vary, even if they were nominally based on the same mathematical formulation.

Each GM exporter is based on a mix of different architectures and languages, so he likelihood of the random numbers being the same on different platforms (as @TheouAegis mentioned) is extremely unlikely.
 

Pfap

Member
Differences in machine architecture, overflow handling, and implementation differences for both the algorithm being used and the language it was being implemented in meant that results could and will vary, even if they were nominally based on the same mathematical formulation.

Each GM exporter is based on a mix of different architectures and languages, so he likelihood of the random numbers being the same on different platforms (as @TheouAegis mentioned) is extremely unlikely.
Hmmm, ok so that's out of the question. It sounds like a lot of typing but if I made my own instructions for how to shuffle an array and then made a few different scripts like shuffle_set1(); shuffle_set2(); etc... Do you think it would be worth it? Or should I just send the order of the cards after shuffling with the built in randomizer? I'll probably just send it over the network, I'm probably pointlessly trying to optimize, but it would be nice if seeds were cross platform.
 

TheouAegis

Member
You could have the host store N random single-byte-length seeds to a buffer and then send that buffer across.

Personally, since we don't really know much about the architecture, I'd just intially focus on assuming all systems will handle it the same and then wait for bug reports to come in. lol that's that everyone else does these days.
 

Pfap

Member
You could have the host store N random single-byte-length seeds to a buffer and then send that buffer across.

Personally, since we don't really know much about the architecture, I'd just intially focus on assuming all systems will handle it the same and then wait for bug reports to come in. lol that's that everyone else does these days.
Yea, I guess that's the problem once the host delivers it to the clients they may not produce the same states from it.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
If I remember correctly, seeding is consistent as of the current version of GMS2. Otherwise you'd get yourself MINSTD or something.

Additionally, I really wouldn't do lockstep on Android unless it's an RTS game and input delay is not noticeable.
 

Pfap

Member
If I remember correctly, seeding is consistent as of the current version of GMS2. Otherwise you'd get yourself MINSTD or something.

Additionally, I really wouldn't do lockstep on Android unless it's an RTS game and input delay is not noticeable.
Cool, I guess I will try it and see what happens. It is the type of game where input delay is not noticeable, more of a board game than an rts though. I'm using a relay server and when the data arrives on the client side it goes in to a que, until that clients' opponent is ready for the extra data.
 
Top