A highly optimized, console-based implementation of Conway's Game of Life written in C++.
Unlike standard implementations that use a fixed, hardcoded 2D array, this engine features an infinitely expanding dynamic grid. It monitors the borders of the simulation and automatically allocates more memory to grow the grid seamlessly as cellular populations migrate outward.
- Infinite Dynamic Expansion: The simulation begins on a randomized 3x3 grid. If a live cell touches the outer boundary, the matrix automatically expands by two rows and columns without losing the current state.
- Optimized Processing: Instead of iterating through every single cell on a massive grid every generation (O(n²) time complexity), this implementation uses secondary memory arrays:
- Secondary Array (
secArr): Tracks only the exact coordinates of currently live cells. - Neighboring Array (
neiArr): Tracks the dead cells immediately adjacent to live cells. - Result: The algorithm only evaluates cells that have the potential to change state, saving massive amounts of CPU cycles.
- Secondary Array (
- Memory Management: Rigorous handling of pointers and dynamic arrays (
newanddelete) to ensure zero memory leaks during grid expansion. - Step-by-Step Animation: Controlled console clears and input pauses allow you to analyze the cellular evolution generation by generation.
The simulation adheres to the classic rules of cellular automata:
- Underpopulation: A live cell with fewer than 2 live neighbors dies.
- Survival: A live cell with 2 or 3 live neighbors lives on to the next generation.
- Overpopulation: A live cell with more than 3 live neighbors dies.
- Reproduction: A dead cell with exactly 3 live neighbors becomes a live cell.
You need a standard C++ compiler (like GCC/G++) installed on your system.
- Clone the repository:
git clone [https://github.com/YourUsername/Your-Repo-Name.git](https://github.com/YourUsername/Your-Repo-Name.git) cd Your-Repo-Name