Cell ecosystem simulator

This is simulator for a cell ecosystem formed by plants, herbivores and carnivores.

Description

  • Green dots are plants. Blue cells are herbivores. Red cells are carnivores.

Technical

  • The simulator is written in C# using Visual Studio 2017.
  • The world is a based in a bitmap. Creatures are the pixels in the bitmap. All data needed by creatures are coded in the color (3 bytes, RGB). No extra data structures are used to store creature information.
  • You can define initial conditions simply drawin a bmp image and importing it in the simulator.

Detailed description

Model

  • The world
    • The world is a square made by cells (“Soil”)
    • Cells can be occupied by creatures
    • Each cell is visualized by a color depending of the creature state
    • Future: Radiation level, World water, different soil cells
  • The creatures
    • Creature state are defined by
      • Energy level
      • Defense and attack levels
      • Future: age, …
    • Energy level
      • From 0 to 100
      • Starts at 50
      • Grows by eating
      • Decreases 1 unit every generation. If energy is 0, the creature dies
    • Trophic level:
      • Plants
      • Herbivores
      • Carnivores
    • Defense level
      • 0 to 150
      • Future: change with mutations, several defense types (chemical, mechanical,…)
    • Attack
      • 0 to 150
      • Future: Can change with mutations
    • Everything is represented using Color RGB

R

G

B

Soil

255

255

0-255

B = 128 + 2*defenseLevel

defenseLevel = 128 – B/2

Plants

0-150

attackLevel = R

155-255

B = 155 + energyLevel

energyLevel = G – 155

0-150

defenseLevel = B

Herbivores

0-150

defenseLevel = R

0-150

attackLevel = G

154-255

energyLevel = B – 155

-1: non activated

Carnivores

154-255

energyLevel = R – 155

-1: non activated

0-150

defenseLevel = G

0-150

attackLevel = B

  • energyLevel color can be 154 at the beginning of simulation. This means creature is not “activated”. It will activate at the first interaction
  • For a cell to be an animal, one and only one color can be > 150
  • A cell with more than one color > 150 is a mutant and it dies. It is converted to soil (128,128,0)
  • A cell with no color > 150 is soil
  • When an animal dies, its cells becames (255, 255, 255)
  • Exemples
    • Soil Soft (255, 255, 74) –> Defense TBD
    • Soil Hard (255, 255, 150) –> Defense 100
    • Plant (150, 255, 75) –> Attack 150, Defense 75
    • Herbivore (75, 100, 255) –> Attack 100, Defense 75
    • Carnivore (255, 0, 100) –> Attack 100

Iterations

  • For each creature
    • For animals, energy decreases by 1
      • Future: Depends on metabolic index for its trophic level
    • If creature has energy = 0 it dies
    • Check creature neighbors (only one check for each condition per iteration)
      • If an enemy exists, check if the creature is eaten
      • If a prey exists, check if the creature eats prey. It can reproduce.
  • Combat
    • A creature wins if
      • Trophic level is one level higher than prey trophic level
      • Attack points > prey defense points
  • Reproduction
    • There is a probability of reproduction
    • Reproduction creates a similar creature in the destination cell with
      • Energy = 50
      • Same trophic level as parent
      • Future: Attack and defense as parent * world_radiation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s