C++20 & Parallel Systems

Conway's Game of Life: Advanced C++20 & Parallel Engine

C++20OpenMPSFMLSOLID ArchitectureMulti-Threading
Conway's Game of Life: Advanced C++20 & Parallel Engine — C++20 & Parallel Systems

Overview & Objective

A deep dive into modern C++20, clean object-oriented software engineering, and parallel performance optimization. Simulates massive cellular automaton grid universes at high framerates using OpenMP multi-core thread distribution, contiguous memory layouts for CPU cache locality, and an extensible architecture strictly adhering to SOLID principles. Features decoupled rendering engines (SFML graphics with dynamic screen auto-resizing vs terminal text), toroidal infinite wrapping, fixed-state obstacle cells, double-buffering state synchronization, and an automated verification unit-testing suite.

Architectural Excellence & SOLID Design

Before writing implementation code, the entire system architecture was drafted through comprehensive UML diagrams. The core engine is orchestrated by JeuDeLaVie, which coordinates decoupled domain classes: - Grille: Encapsulates dynamic 2D grid allocation, boundary checking, and generation swapping. - Cellule: Represents individual cell states (dead, alive, obstacle). - Fichier: Manages persistent file I/O for saving and loading complex automaton seed patterns. - Affichage: Abstract base class adhering to the Open/Closed Principle, allowing new visualizers (Console, SFML) to plug in without altering simulation logic.

Engineering Challenges & Lessons Learned

Double-Buffering State Synchronization

Cells cannot update their live state while neighboring cells are still computing their next generation. Implemented a double-buffering scheme separating current generation buffers from next generation allocations to eliminate state bleeding.

OpenMP Concurrency & Portability

Deploying OpenMP multithreading across diverse compilers (GCC, Clang, MSVC) required careful handling of thread-private index variables and compiler-specific flags to prevent data races on shared memory.

Dynamic Screen Scaling

Implemented an auto-scaling coordinate mapping function in AffichageGraphique ensuring arbitrary grid dimensions (from 10x10 to 200x200) fit the SFML window without aspect distortion.

Visual Documentation

Engineering Artifacts & Diagrams

Click any diagram or visual artifact to examine in high resolution.

Complete UML Class Diagram

Complete UML Class Diagram

Object-oriented class hierarchy detailing relationships between JeuDeLaVie, Grille, Cellule, Fichier, and the abstract Affichage hierarchy.

UML Use Case Diagram

UML Use Case Diagram

User interaction pathways mapping grid generation (file, random, manual), display selection, and simulation execution.

Simulation Lifecycle Activity Diagram

Simulation Lifecycle Activity Diagram

Activity flow tracing initialization, generation step updates, double-buffered state swapping, and rendering triggers.

General Lifecycle Sequence Diagram

General Lifecycle Sequence Diagram

Sequence of message exchanges between core components during simulation setup and execution.

Grid State Update Sequence

Grid State Update Sequence

Detailed sequence showing neighbor counting and simultaneous generation updates to prevent state bleeding.

SFML Graphics Rendering Sequence

SFML Graphics Rendering Sequence

Interactions between the graphics renderer, SFML window event loop, and cell color updates.

Toroidal Wrapping Grid Concept

Toroidal Wrapping Grid Concept

Modular arithmetic concept wrapping top/bottom and left/right boundaries into an infinite donut topology.

Modular Boundary Code Implementation

Modular Boundary Code Implementation

Clean C++ modular arithmetic safely wrapping cell coordinates without out-of-bounds memory errors.

Obstacle Cell Implementation

Obstacle Cell Implementation

Encapsulated state constraints allowing fixed obstacle cells to influence neighbor counts indefinitely.

OpenMP Multithreading Directive

OpenMP Multithreading Directive

OpenMP parallel loop directives distributing cellular neighbor calculations across multi-core processors.

Automated Unit Verification Suite

Automated Unit Verification Suite

Unit test framework asserting deterministic grid generation states against verified baseline outputs.

Main Game Loop Architecture

Main Game Loop Architecture

Encapsulated JeuDeLaVie::start() method maintaining clean, self-documenting high-level control flow.

Terminal Console Rendering

Terminal Console Rendering

Minimalist, fast text-based cellular grid rendering directly in terminal output.

SFML GUI Display (Small Grid)

SFML GUI Display (Small Grid)

Real-time 2D graphical display of cellular patterns with dynamic square scaling.

SFML GUI Display (Dense Grid Universe)

SFML GUI Display (Dense Grid Universe)

Dense 200x200 grid universe running smoothly at high framerates backed by OpenMP parallel computation.

Key Engineering Highlights

SOLID Object-Oriented Architecture

Strict separation of concerns between simulation lifecycle (JeuDeLaVie), state management (Grille), individual cell behavior (Cellule), persistence (Fichier), and polymorphic rendering (Affichage).

Multi-Core OpenMP Parallelization

Parallelized cell neighbor counting across multiple CPU cores with OpenMP, maximizing cache locality on contiguous grid buffers.

Dual Polymorphic Rendering (SFML & Console)

Polymorphic display architecture supporting both low-overhead ASCII terminal output and GPU-accelerated SFML 2D rendering with dynamic auto-resizing.

Toroidal Grid & Fixed Obstacle Cells

Modular arithmetic topology for infinite seamless edge-wrapping, combined with indestructible obstacle cells influencing neighborhood evolution.

Execution & Quickstart Commands

Compilation (Makefile)Compiles C++20 source with OpenMP and SFML dependencies.
make
Run SimulationLaunches interactive console/GUI cellular automaton engine.
./main