Search code examples
python-2.5cellular-automata

Cellular automaton with more then 2 states(more than just alive or dead)


I am making a roguelike where the setting is open world on a procedurally generated planet. I want the distribution of each biome to be organic. There are 5 different biomes. Is there a way to organically distribute them without a huge complicated algorithm? I want the amount of space each biome takes up to be nearly equal.

I have worked with cellular automata before when I was making the terrain generators for each biome. There were 2 different states for each tile there. Is there an efficient way to do 5?

I'm using python 2.5, although specific code isn't necessary. Programming theory on it is fine.

If the question is too open ended, are there any resources out there that I could look at for this kind of problem?


Solution

  • You can define a cellular automaton on any cell state space. Just formulate the cell update function as F:Q^n->Q where Q is your state space (here Q={0,1,2,3,4,5}) and n is the size of your neighborhood.

    As a start, just write F as a majority rule, that is, 0 being the neutral state, F(c) should return the value in 1-5 with the highest count in the neighborhood, and 0 if none is present. In case of equality, you may pick one of the max at random.

    As an initial state, start with a configuration with 5 relatively equidistant cells with the states 1-5 (you may build them deterministically through a fixed position that can be shifted/mirrored, or generate these points randomly).

    When all cells have a value different than 0, you have your map.

    Feel free to improve on the update function, for example by applying the rule with a given probability.