This project is a desktop implementation of Conway's Game of Life, built using modern .NET and WPF. It follows the MVVM (Model-View-ViewModel) architecture to ensure a clean separation between the simulation logic and the user interface.
- Dynamic Simulation: Start, stop, and control the speed of the simulation.
- Step-by-Step Execution: Advance the simulation one generation at a time to observe changes.
- Interactive Board: Manually toggle the state of cells by clicking on them when the simulation is paused.
- Customizable Setup:
- Define the board's width and height.
- Specify custom rules for cell survival and birth (e.g., "B3/S23").
- Choose custom colors for alive and dead cells.
- Initialize the board with predefined patterns.
- State Persistence: Save the current game state (board and rules) to a file and load it later.
- Real-time Statistics: View statistics such as the current generation number.
The solution is structured into three distinct projects, adhering to the principles of clean architecture and the MVVM design pattern.
-
GameOfLife.Core: A .NET class library that contains all the core business logic.- Models:
Board,Cell,Rules, andStatistics. - Services:
SimulationServicefor running the simulation logic andFileServicefor saving/loading the game state. - This project is completely independent of the UI, making the core logic portable and easy to test.
- Models:
-
GameOfLife.WPF: The main WPF application that provides the user interface.- Views: XAML files that define the structure and appearance of the UI (
MainWindow,InitializationWindow,BoardControl). - ViewModels: Classes that manage the application's state and logic, acting as a bridge between the Views and the Models (
MainViewModel,InitializationViewModel). - MVVM Pattern: Utilizes
CommunityToolkit.Mvvmfor implementingObservableObjectandRelayCommand. - Dependency Injection: Services from the
Coreproject are injected into the ViewModels.
- Views: XAML files that define the structure and appearance of the UI (
-
GameOfLife.Tests: A test project for unit testing the logic withinGameOfLife.Coreand the ViewModels inGameOfLife.WPF.
- .NET
- C#
- WPF (Windows Presentation Foundation)
- MVVM Design Pattern
- CommunityToolkit.Mvvm
- Microsoft Extensions for Dependency Injection