sequba / h3mapgen-cellular-terrain

Part of the Heroes 3 Map Generator. Module builds terrain shape using cellular automata.
1 stars 0 forks source link

h3mapgen-cellular-terrain

Part of the Heroes 3 Map Generator. Module builds terrain shape using cellular automata.

Data representation description:

The game map (board) is represented as a 2-d vector of cells. Namely: typedef vector<vector<Cell> > Board;

A single cell can be in one of 4 states: white, black, swhite or sblack:

enum Cell {
        white,  black,
        swhite, sblack
};

How to use the generator?

First of all, you need to include the header: #include "cellular_terrain.hpp".

Then take a look on facade function terrain(...) as well as specialized neighbourhood functions:

void terrain(const Board& board, Board& result, const TerrainParams& parameters, unsigned int iterations);
TerrainParams *_neighbourhood(float probability, int self_weight=1, int threshold=0);

Example usage:

terrain(my_map, terrain_map, moore_neighbourhood(0.5), 2);
terrain(my_map, terrain_map, neumann_neighbourhood(0.4, 3), 4);
terrain(my_map, terrain_map, moore_neighbourhood(0.4, 1, 5), 3);

A quick glance at the code in facade_test.cpp would leave no doubts, I belive.

Which files exactly do you need?

Just four of them:

As a bonus, you may also want to use my ascii -> bmp conversion for resulting maps. Then you'll need draw.cpp in addition.

The report

For the thorough description of the method used, theoretical background, some interesting findings and practical tips, see the project report (the PDF file in the report directory).

Note

Bash scripts producing maps require imagemagick.