During my work on the Unreal Conway Game Of Life Project, I developed a C++ implementation of Conway's Game of Life using Unreal Engine. Below are some of the key achievements:
Below is a key code snippet demonstrating the core Conway's Game of Life algorithm implementation from the project:
#include "ConwayGame.h"
// Update the grid based on Conway's Game of Life rules
void AConwayGame::UpdateGrid()
{
TArray> NewGrid = Grid;
for (int32 Row = 0; Row < Grid.Num(); ++Row)
{
for (int32 Col = 0; Col < Grid[Row].Num(); ++Col)
{
int32 AliveNeighbors = CountAliveNeighbors(Row, Col);
if (Grid[Row][Col])
{
NewGrid[Row][Col] = AliveNeighbors == 2 || AliveNeighbors == 3;
}
else
{
NewGrid[Row][Col] = AliveNeighbors == 3;
}
}
}
Grid = NewGrid;
}
int32 AConwayGame::CountAliveNeighbors(int32 Row, int32 Col) const
{
int32 Count = 0;
for (int32 i = -1; i <= 1; ++i)
{
for (int32 j = -1; j <= 1; ++j)
{
if (i == 0 && j == 0) continue;
int32 NeighborRow = Row + i;
int32 NeighborCol = Col + j;
if (NeighborRow >= 0 && NeighborRow < Grid.Num() &&
NeighborCol >= 0 && NeighborCol < Grid[NeighborRow].Num() &&
Grid[NeighborRow][NeighborCol])
{
++Count;
}
}
}
return Count;
}
Unreal Conway Game Of Life Project is an innovative simulation project that features the implementation of Conway's Game of Life algorithm to create dynamic cell behaviors in a 3D environment using Unreal Engine 5. The project showcases advanced AI techniques and efficient code structure.