87 lines
3.8 KiB
Markdown
87 lines
3.8 KiB
Markdown
# Game of Life: Extended Version
|
|
|
|
## Overview
|
|
|
|
The Game of Life was originally created by mathematician John Conway in 1970. It is a cellular automaton where cells are placed on a grid and evolve through iterations based on a set of rules the user is free to implement.
|
|
For our project of the game of life, we introduced additional states (rules and cells behaviours) and two agents that modify the cells' behavior, providing a more complex and dynamic simulation.
|
|
|
|
## Cell States
|
|
|
|
The cells in this version of the Game of Life can exist in one of five states:
|
|
|
|
- **Dead (Considered state 0)**: No living cell is present.
|
|
- **Young (Considered State 1)**: A young cell that has just been born.
|
|
- **Middle-aged (Considered State 2)**: A cell that has aged from young.
|
|
- **Old (Considered State 3)**: A cell that has aged from middle-aged.
|
|
- **Infected (Considered State 4)**: A cell that has been infected by a Virus agent.
|
|
|
|
## Rules
|
|
|
|
### Basic Rules
|
|
|
|
1. **Young Cells (State 1)**:
|
|
- **Survival**: A young cell survives if it has 2 or 3 neighbors.
|
|
- **Aging**: A young cell ages to a middle-aged cell (State 2) after one cycle.
|
|
|
|
2. **Middle-aged Cells (State 2)**:
|
|
- **Survival**: A middle-aged cell survives if it has 2, 3, or 4 neighbors.
|
|
- **Aging**: A middle-aged cell ages to an old cell (State 3) after one cycle.
|
|
|
|
3. **Old Cells (State 3)**:
|
|
- **Survival**: An old cell survives if it has 1, 2, or 3 neighbors.
|
|
- **Death**: An old cell dies (becomes State 0) after one cycle.
|
|
|
|
4. **Dead Cells (State 0)**:
|
|
- **Birth**: A dead cell gives birth to a young cell (State 1) if it has exactly 3 neighbors.
|
|
- **Birth from Old Cells**: A dead cell gives birth to a young cell (State 1) if it has exactly 4 old cell neighbors (State 3).
|
|
|
|
### Agent Rules
|
|
|
|
#### Virus Agent
|
|
|
|
- The Virus agent moves randomly around the grid.
|
|
- When the Virus agent lands on a cell, it infects the cell, changing its state to 4 (infected).
|
|
- The Virus agent does not die or reproduce; it continuously moves around infecting cells.
|
|
|
|
#### Infected Cells (State 4)
|
|
|
|
- Infected cells are cells that have been infected by a Virus agent.
|
|
- Infected cells do not reproduce or evolve into other states.
|
|
- Infected cells die after 3 cycles, becoming dead cells (State 0).
|
|
|
|
## Implementation
|
|
|
|
### Initialization
|
|
|
|
The grid is initialized with cells in various states, and Virus agents are placed at random locations.
|
|
|
|
### Iteration
|
|
|
|
During each cycle (iteration) of the game, the following steps occur:
|
|
|
|
1. **Update Cells**:
|
|
- Apply the basic rules to each cell on the grid based on its current state and the states of its neighbors.
|
|
|
|
2. **Move Virus Agents**:
|
|
- Each Virus agent moves to a new random location on the grid.
|
|
- If a Virus agent lands on a cell, it changes that cell's state to infected (State 4).
|
|
|
|
3. **Update Infected Cells**:
|
|
- Decrease the infection cycle count for each infected cell.
|
|
- If an infected cell has completed 3 cycles, it becomes a dead cell (State 0).
|
|
|
|
### Example Cycle
|
|
|
|
1. **Young Cell (State 1)** with 2 or 3 neighbors will survive and age to Middle-aged (State 2).
|
|
2. **Middle-aged Cell (State 2)** with 2, 3, or 4 neighbors will survive and age to Old (State 3).
|
|
3. **Old Cell (State 3)** with 1, 2, or 3 neighbors will survive but will die (State 0) after one cycle.
|
|
4. **Dead Cell (State 0)** with exactly 3 neighbors will become a Young cell (State 1).
|
|
5. **Old Cell (State 3)** with exactly 4 neighbors will create a Young cell (State 1) in a dead cell (State 0).
|
|
|
|
### Virus Interaction
|
|
|
|
1. Virus agents move randomly.
|
|
2. Cells they land on become Infected (State 4).
|
|
3. Infected cells die after 3 cycles, becoming Dead (State 0).
|
|
|
|
This extended version adds more layers of complexity to the classic Game of Life, creating opportunities for more intricate and unpredictable patterns to emerge on the grid. |