Handmade Hero»Forums»Code
9 posts
Day 084 RandomSeed weirdness....
Edited by Jeff on
I am on day 084 and when I use

random_series Series = RandomSeed(1234); for the world generation at the top of GameUpdateAndRender()) I get a completely different world then Casey does...

I cut and paste the RandonNumberIndex from Casey's HandmadeRandom.H to make sure I was using the same information...Is it possible that because I am using MSVC as the editor and compiler there is some floating point weirdness or an option I have checked that is causing a problem?

The "App" works fine, its just that my world and splats are totally different...Also the walls and the series of rooms are oriented differently, but they change with different seed #'s...

Any thoughts???
Mārtiņš Možeiko
2562 posts / 2 projects
Day 084 RandomSeed weirdness....
Wall orientation depends only on integer number generation, so floating point accuracy cannot mess it up.
Are you sure you implemented integer random number generation correctly? What is RandomNumberIndex? I don't see such variable or function in handmade_random.h file.
Are you sure you are using random number generation (RandomChoice) during wall generation in exactly same way as Casey? Because if you call it with different arguments, or in different order - the world will be different.
9 posts
Day 084 RandomSeed weirdness....
I meant RandomNumberTable not Index...The list of Hex #'s...
9 posts
Day 084 RandomSeed weirdness....
Found the problem and it was really obscure...

I typed #define ArrayCount(Array) (sizeof(Array)) / sizeof((Array[0]))

Instead of #define ArrayCount(Array) (sizeof(Array) / sizeof((Array)[0]))

in Handmade_Platform.H and for some reason it flipped the whole word on its side as far as world generation goes...only took 6 1/2 hours to find, and ironically it was in the last place that I looked.
Miguel Lechón
78 posts / 2 projects
Day 084 RandomSeed weirdness....
and ironically it was in the last place that I looked.
Ironically?? It was the in the last placed you looked because you stopped looking after you found it!

Anyways, good catch. I had to read your two #defines several times in order to spot the difference.
9 posts
Day 084 RandomSeed weirdness....
Edited by Jeff on
I have a running joke with my wife if I can't find my wallet or keys...When I find them she will say "where were they? Probably the last place you looked.?" After a while I started telling her, "no I continued to look for them after I found them." Just to make sure they weren't in the last place I looked.