Guys, after a finish my problems with tilemaps… i get stucked on next subject … my random dungeon is not random … i rebuild the project and it comes the same and the same … forever.
I checked if i had problem on using math.random(4,7) but i check on lua and it should work.
I’m not a super expert at Lua yet so I can’t comment on any flaws the standard math.random may have. But I think it’s still a good idea to use the non-standard for gamedev related randomness. Many games do use standard random functions and so have flaws such as having randomly generated game boards, but every 200 levels or so you are statistically guaranteed to have played the same exact level at least twice…
By the way, if you want to generate dungeons that are not all the same but each is constructed the same every time that specific level is generated you can use a method of building such as setting the seed each time you generate a random number to generate something based on like: level id + step. You reset the seed, and then generate a value immediately with each step. This ensures that you generate the same values every time. This is useful if you want to build a daily challenge type of mode (seen in games like Spelunky or Crypt of the NecroDancer) where everyone in the world gets the same dungeons exactly to play each day without relying on a server to deliver dungeon data. However a thing to be aware of with this is that different OS may have different way of doing functions which the PRNG relies on, which means the random steps may not always be the same on Windows vs Linux… you would have to test.
oh ty that was very very interesting … i will think on something like this … but most interesting thing was that is possible to generate identical dungeons for different ppl. Ty alot