Ecosystem Simulation Rules
Plant Rules:
- Growth: Plants have a 5% chance to grow each turn.
- Reproduction: When a plant's energy exceeds twice its initial energy, it attempts to create a new plant in an adjacent empty cell.
- Energy: Plants start with 3 energy units and gain 1 energy unit when they grow.
Herbivore Rules:
- Movement: Herbivores move to an adjacent empty cell or towards nearby plants each turn.
- Feeding: Herbivores can eat up to 3 plants in a single turn when adjacent to them.
- Reproduction: When a herbivore's energy exceeds its maximum (20 units), it has a 30% chance to create a new herbivore in an adjacent empty cell.
- Energy: Herbivores start with 20 energy units, lose 1 unit per turn, and gain energy by eating plants.
- Spawning: Every 4 seconds, 3 new herbivores are added to random empty cells on the grid.
Carnivore Rules:
- Movement: Carnivores move to an adjacent empty cell or towards nearby herbivores each turn.
- Feeding: Carnivores can eat 1 herbivore in a single turn when adjacent to it.
- Reproduction: When a carnivore's energy exceeds its maximum (30 units), it has a 30% chance to create a new carnivore in an adjacent empty cell.
- Energy: Carnivores start with 30 energy units, lose 1 unit per turn, and gain energy by eating herbivores.
Wall Rules:
- Placement: Walls are placed in a grid pattern, creating "rooms" within the ecosystem.
- Interaction: No creature can move through or occupy a wall cell.
General Rules:
- Grid: The simulation takes place on a 30x30 grid.
- Death: Any creature (herbivore or carnivore) dies when its energy reaches 0.
- Wraparound: The grid wraps around, so creatures can move from one edge to the opposite edge.
Simulation