The Game
The Game of Life, also known as Conway's Game of Life or simply Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.[1] It is a zero-player game,[2][3] meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.
Rules
The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead (or populated and unpopulated, respectively). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Implementation
This implementation of Conway's Game of Life is written in C and uses the Raylib library for rendering and user interaction. The simulation is displayed on a 2D grid, where each cell represents either a live or dead state. The rules of the game are applied to determine the next generation of cells based on their neighbors.
Features
- Random Grid Generation: The initial state of the grid is generated randomly.
- Next Generation Calculation: The grid evolves based on Conway's rules.
- Camera Controls: Navigate the grid using keyboard inputs.
- Zoom Functionality: Adjust the zoom level for better visualization.
Controls
- Keyboard:
W/S
: Move up/down.A/D
: Move left/right.[SPACE]
: Pause and ResumeX
: Show/Hide Grid's lines[TAB]
: Show/Hide UIC
: Clear the gridR
: Generate random grid
- Mouse Scroll: Zoom in/out.
- Fullscreen Toggle: Use the checkbox to enter or exit fullscreen mode.
Technical Details
The simulation uses two grids to store the current and next generation states. The Raylib library is used for rendering the grid and handling user input. The game runs at 60 frames per second, ensuring smooth visualization of the simulation.