How do you properly and efficiently generate random numbers and noise for map generation?

fl4v1u5fl4v1u5 Posts: 2Member
edited February 11 in Programming

I've been playing around with Godot for a while, and I decided to try and test programming an ASCII graphics (so, only using 2D here) game with Godot.
It takes less than half a second for my computer to generate 6728 (116 rows and 58 columns) of '.' symbols. I tried a couple of things, ran into some errors that were easy to overcome but one of them isn't.
A big thing about games with ASCII graphics (mostly roguelikes, I'm thinking of Dwarf Fortress and CDDA) is random map generation.

So I tried to generate a "space map" with white '*' symbols on a black background. Less than 0.5 seconds. Then I added a condition, for which the game would draw a '*' only if a random integer between 1 and 10 was bigger than 9, so that's 10% of the times.

The result isn't too bad for what I'm trying to do, but the problem is it takes my computer about 45 seconds to generate this. And the only thing I added was this

var rndi = randi()%11+1
if rndi > 9:
    map[x][y][1] = '*'
else :
    map[x][y][1] = ''

condition. So clearly generating random numbers is something my computer can't do in a comfortable time.

So basically I would like to know in what ways do roguelikes generate random maps, and what ways of generating a random map full of features there are without my computer melting after 2 hours of programming and testing.

My plan was to generate different levels of maps, in which the sun would be a small part of the bigger map, then when you enter the solar system each planet has its own sector and so on. Sort of how the game "The Ur-Quan Masters" works. But if by only generating star symbols which hold no additional information it takes my computer 45 seconds, I clearly need a better way of doing this before my generation times get to hour-levels.

Thank you in advance for reading and helping!

Edit: It takes 45 seconds with google chrome open and running, it takes about 7 seconds without it lol....chrome is the programmer killer

Sign In or Register to comment.