To complete this tutorial you'll need a noise generator (Perlin, Simplex, Voronoi, etc...) as well as an implementation of the A* algorithm (or something similar).

**Step 1**

Generate a tile map. The map should be as big as the bounding box that encapsulates your path. That is, if your path stretches from [10, 10] to [110, 110], your tile map will be 100 x 100.

__Step 2__

Populate your map with random values based on whichever noise function you chose. Note that you can simply make it completely random but for best results, don't. In this screenshot, I've used Perlin noise to generate a map which I then drew by interpreting each cell's value as the green value.

__Step 3__This is the important bit: Set up your A* function to calculate the F costs (distance from your source to your target, where the source is our river's starting point and the target is your river's endpoint) to include each cell's random value. Each cell's F cost will be equal to: distance to the target + cell's random value.

__Step 4__**Using your AI, build a path between the two points. Because we used the noise function to influence our F costs the path will be interesting and unique, rather than straight and boring.**

__Further Steps__

You can also implement a little recursive function that will 'fill' an area where the river ends by interpreting the height at the endpoint and making the water tile overflow onto any tiles that are lower than your initial tile.

If you have any further questions, feel free to leave a message.

How about a Perlin noise tutorial? With pseudo code? Pretty please?

ReplyDeleteThis comment has been removed by the author.

Delete