Extreme Use of the GD Library

I want to see if it is possible to use the GD Library to randomly generate physical map that is similar to the Earth. At this stage I’m just wondering if this can be done with PHP. I know for a fact that this has been done with Python and has been implemented in a game called Civilization IV, however after much peering through the source code has left me with nothing. Plus I don’t know Python.

I would think that being able to generate a bunch of ovals with fractal edges and somehow not make them generate on top of each other and filling them with color would be enough, but the fractal edge part escapes me.

Of course it’s possible. It mightn’t however be the simplest, nicest or most fun way to do it, but it is definitely possible.

Civilization, I believe, operates on a simpler (or at least less mathematically complex) technique. I don’t believe it involves fractals at all. It simply uses a combination of functions that keep like terrain types “clumped” and reasonably together while at the same time grabbing random numbers to change the terrain type from one grid square to another. This is a computationally simple way to generate grid-based maps for a game.

You’ll note that Civilization does throw in a little application logic. Deep sea squares do not occur unless there are shallow sea squares between them and any land squares. Hill squares “typically” occur between mountains and flat land forms, etc.

Fractals are a way to use simple math functions to generate complex displays that are self-similar at variable levels of magnification (and this is a characteristic of realistic landscapes which is why fractals have been used to generate them). However, I believe the implementation would be more difficult than Civilization.