Hugoagogo
Hugoagogo

Reputation: 1646

Generate a polygon of landmasses in python

Is anyone able to recommend a generator, algorithm or any other easy way of generating a bunch of random landmasses to make up a planet.

The idea is that i will be able to project this onto a circle (my game is 2d) and rotate it so it is a vectorish world map kind of thing.

Also as this is a aesthetic part of the game im not too worried if the planet doesn't have regular features like landmasses at the poles ect.

The language i am using is python but if anyone has a generator with an api i can access im happy to go along that kind of path

Upvotes: 3

Views: 1039

Answers (3)

P2bM
P2bM

Reputation: 1048

You could try the Random midpoint displacement method to first generate the vertex map, then transfer it to spherical coordinates to make it into a ball.

Upvotes: 0

Monkey
Monkey

Reputation: 1866

Algorithm to generate natural looking terrains http://en.wikipedia.org/wiki/Perlin_noise Google will give you plenty of implementation for it. It gives you an heighfield, so a threshold to classify a point as either land or water gives you land masses.

If you need the land masses as polygons, you can run the marching square algorithm to get the polygon from the pixel map http://en.wikipedia.org/wiki/Marching_squares

Upvotes: 1

nitrogenycs
nitrogenycs

Reputation: 972

You could use http://pypi.python.org/pypi/noise/ and then apply a smoothing and/or power filter and finally a thresholding function.

Also, do you want vector output or bitmap output?

EDIT: Please delete, I didn't read the "polygon" in the headline.

Upvotes: 0

Related Questions