[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Random Terrain Generator



Beautiful :)

I'm not going to be around till Tuesday so I'll read this in detail later.

Jon


Quoting Kris Schnee <kschnee@xxxxxxxxxx>:

> > Nice screenshot.  Is that multiple runs of the terrain generator tiled, or
> one run?
> 
> Thanks. The screenshot is one run of another program making the 
> generator run repeatedly, then applying a texture heightmap (like, 
> anything in a certain height range is blue), then blitting the little 
> maps into a big surface and saving it.
> 
> 
> JoN wrote:
> > By the way -
> > 
> > Given the same input parameters will it generate the same terrain every
> time, or
> > is it random ?
> 
> Yes. 8)
> 
> It uses the function random.randint(), so the numbers involved are as 
> random as you can get with a computer... but by calling random.seed(), 
> you can feed the number generator some data and get the same terrain 
> every time.
> 
> In the screenshot:
> http://kschnee.xepher.net/pics/061025skygold.jpg
> You can see what happened when I called seed() using the X,Y coordinates 
> of a game-world "zone," on the theory that every time you visited zone 
> (4,2) it'd be the same even though it's "random." But I found there was 
> this weird repetition. Looking into it, I found that seed() was calling 
> hash(), and that (say) the values (1,-1) and (1,-2) had the same hash 
> value, causing copies of the same islands to get generated. Not good. 
> The solution hashed out was to mess with the data some more, to be 
> relatively sure of getting unique hash values for each coordinate pair. 
> The result was this:
> http://kschnee.xepher.net/pics/061025skygold2.jpg
> Which has no obvious repetition. Still, there's an obvious grid of 
> similarly-sized islands. I tried making bigger zones and found that my 
> algorithm wasn't very well suited to the 300x300 size, and that it still 
> gave me an obvious grid. So, what I'm thinking of doing now is to make 
> some zones more flooded than others, so that some have little or no 
> land, reducing the sameness of the world and creating more water areas 
> instead of the street-like NSEW waterways seen above. Another option 
> would be to somehow alternate semi-randomly between big zones (2x2, 3x3) 
> and little ones, or to semi-randomly switch between algorithms.
> 
> I made this partly in reaction to traditional random dungeon games, 
> which I dislike (except for "Disgaea!"). By using a seed function it's 
> possible to avoid the problem that everybody's game is different. I made 
> fun of the randomness in an article on RPGamer.com:
> http://www.rpgamer.com/editor/2001/q3/070601ks.html
> 
> By the way, I did a couple of random-content generators using Python and 
> CGI, here:
> http://kschnee.xepher.net/generators.htm
> 
> Kris
> 




--------------------------------------------------------------------
Come and visit Web Prophets Website at http://www.webprophets.net.au