A downloadable project for Windows

Conway's Game of Life

Git: GitLink

Check git release for videos.

Implementation Strategies

Ticks:

A tick cycle is the interval between each time the data of each cell is updated using the variant of rules of “game of life”.

By separating the tick cycle from the rendering cycle, higher fps can be achieved.

The default tick rate of this project is set to 4 ticks per second.

Rendering:

Use unity built-in render pipeline and GPU instancing. Use graphic API Graphics.DrawMeshInstancedIndirect together with custom shader to set the customized graphic buffer to render the grid. Draw instances each frame in update loop.

Update the graphic buffer at a lower rate to minimize cpu usage.

A system will collect all the coordinate info from data buffers and prepare the data before setting the graphic buffer.

Job Scheduling:

Divide the grid into chunks of size 100*100 and update the data using IJobChunk. Because the size of each ECS chunk is 16Kbyte, by organizing the data into buffer with each of size 100*100 will ensure each chunk contains only one entity.

Each job update and write to its’ own data buffer in parallel. A single data buffer with entire grid data from previous tick cycle is used for jobs to read data in parallel. After all jobs are completed, the single data buffer is then updated in the main thread.

Frame Rate Smoothing:

With increasing number of data chunks, it will take longer for all jobs to finish. If the grid size is 5000x5000, data chunks will be 2500. Scheduling all of them in one frame will result in a supper long frame, which causes stutter.

By dividing jobs and batching them in different frames, the lowest fps will be smoothened and stutter is removed. Lowest 1% fps improved to 47 in 5000x5000 grid set up with random initial data.

Possible To Do List:

  • Use IJob for each data chunk instead of IJobChunk and Schedule them individually. Don’t set the dependency for each job handle and manually check the completion of each job. This will get smoother results.
  • Use render texture for grid drawing. This can help get larger grid size. 5000x5000 quad instances already used more than 50% of my GPU in 4K resolution. (RTX 4090). But it loses the flexibility to change the mesh.
  • UI and features to change the grid size any time.

Testing Results and Initial Data:

 

The Initial data will affect the test results due to the implemented algorithm.  

Initial data set 1: Randomized

Initial data set 2: Even cell is live, odd cell is dead.

 

Set1

Set2

2500x2500

avg 1200fps, lowest 1% 460fps

avg 540fps, lowest 1% 200fps

5000x5000

avg 350fps, lowest 1% 65fps

avg 130fps, lowest 1% 47fps

7000x7000

avg 200fps, lowest 1% 35fps

avg 66fps, lowest 1% 23fps

 7000x7000 Random initial data

7000x7000 Odd Live Initial data

Specs:

CPU: i9-13900KF

GPU: RTX4090

RAM: 32GB

OS: Windows 11

Resolution: 3840x2160

Download

Download
GameOfLife5000x5000Random.zip 29 MB
Download
GameOfLife2500x2500OddEven.zip 29 MB
Download
GameOfLife7000x7000OddEven.zip 29 MB
Download
GameOfLife5000x5000OddEven.zip 29 MB
Download
GameOfLife2500x2500Random.zip 29 MB
Download
GameOfLife7000x7000Random.zip 29 MB

Leave a comment

Log in with itch.io to leave a comment.