ConwaysGameOfLife 1.1.2
dotnet add package ConwaysGameOfLife --version 1.1.2
NuGet\Install-Package ConwaysGameOfLife -Version 1.1.2
<PackageReference Include="ConwaysGameOfLife" Version="1.1.2" />
paket add ConwaysGameOfLife --version 1.1.2
#r "nuget: ConwaysGameOfLife, 1.1.2"
// Install ConwaysGameOfLife as a Cake Addin #addin nuget:?package=ConwaysGameOfLife&version=1.1.2 // Install ConwaysGameOfLife as a Cake Tool #tool nuget:?package=ConwaysGameOfLife&version=1.1.2
Conway's Game of Life Library
This is a C# .NET 6 library that implements Conway's Game of Life. It allows users to create a game instance, set initial states of cells, and iterate through generations.
Installation
Clone the repository or download the source code and add it to your project as a reference.
Usage
First, create a GameOfLifeBuilder instance to set up the game parameters, such as width, height, and game mode. Then, use the builder to create a new instance of the game.
bool[,] initialBoard =
{
{ false, false, false },
{ false, true , false},
{ false, false, false }
};
GameOfLifeBase game = new GameOfLifeBuilder()
.SetAsClassicGameOfLife()
.SetWidth(3)
.SetHeight(3)
.SetInitialGeneration(initialBoard)
.Build()
To iterate through generations, call the NextGeneration() method.
game.NextGeneration();
To get the current state of the board, call the GetCurrentBoard() method. To get the state of a specific cell, call the GetCell(int x, int y) method.
bool[,] currentBoard = game.GetCurrentBoard();
bool isCellAlive = game.GetCell(1, 1);
To set the state of a specific cell, call the SetCell(int x, int y, bool isAlive) method.
game.SetCell(1, 1, true);
Testing
The library comes with a set of unit tests to ensure the correctness of its implementation. Tests can be found in the ConwaysGameOfLifeTests directory.
Contributing
Contributions to this library are welcome. Please submit a pull request with your changes.
License
This library is licensed under the MIT License. See the LICENSE file for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New Features : Added Serialize and Deserialize methods to the GameOfLifeBase class for easier serialization and deserialization of game state. Added unit tests for the new methods.
Bug Fixes : Fixed a bug where ClassicGameOfLife would not correctly calculate the next generation for certain configurations. Improvements : Improved performance of the GameOfLifeBase class for large game boards. Improved documentation and code readability.