I've got problem with this ... =)

Cellular Automata – Sharks and Fishes
A concept that is particularly suitable for synchronous iteration is called cellular automata. In this approach, the problem space is first divided into cells. Each cell can be in one of a finite number of states. Cells affected by their neighbors according to certain rules, and all cells are affected simultaneously in a “generation”. Rules are re-applied in subsequent gene rations so that cells evolve, or change state, from generation to generation.

An example of cellular automata is “Sharks and Fishes”. An ocean could be modeled as a three-dimensional array of cells, each cell can hold with different behavior rules, one fish or one shark (but not both). Fish and sharks follow “rules”.

Fish - Might move around according to these rules:
1. If there is one empty adjacent cell, the fish moves to this cell.
2. If there is more than one empty adjacent cell, the fish moves to one cell chosen at random.
3. If there are no empty adjacent cells, the fish stays where it is.
4. If the fish moves and has reached its breeding age, it gives birth to a baby fish, which is left in the vacating cell.
5. Fish die after x generations.

Sharks - Might be governed by the following rules:
1. If one adjacent cell is occupied by a fish, the shark moves to this cell and eats the fish.
2. If more than one adjacent cell is occupied by a fish, the shark chooses one fish at random, moves to the cell occupied by the fish, and eats the fish.
3. If no fish in adjacent cells, the shark chooses an unoccupied adjacent cell to move to in a similar manner as fish move.
4. If the shark moves and has reached its breeding age, it gives birth to a baby shark, which is left in the vacating cell.
5. If a shark has not eaten for y generations, it dies.


Using C++
It should be like thise
[IMG]http://i55.tinypic.com/zlc7rs.jpg[/IMG]
http://i55.tinypic.com/zlc7rs.jpg


So can u help me to write it ?>.<
Topic archived. No new replies allowed.