Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
A jam submission

GameOfLifeDOTSView project page

Game of life implemented using unity DOTS
Submitted by xy90@live.com.sg — 3 days, 2 hours before the deadline
Add to collection

Play project

GameOfLifeDOTS's itch.io page

Git Repository
https://github.com/stdlibdoth/game-of-life.git

Performance Strategy
Conway's Game of Life
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

Specs:
CPU: i9-13900KF
GPU: RTX4090
RAM: 32GB
OS: Windows 11
Resolution: 3840x2160

Leave a comment

Log in with itch.io to leave a comment.

Comments

Submitted

Having a strange issue where most times I run the program, the cells disappear off the left side of the screen. I think just spamming keys or left click when opening the program makes it less likely to happen?

Am I understanding correctly that the top left ui shows how many ticks per second are being simulated? image.png

Developer (1 edit)

Yes, the top left is showing how many ticks per second being simulated.

I'm not sure why the cells disappear off the left side of the screen. I haven't encounter the issue you mentioned.
I recorded the videos on my computer: https://drive.google.com/drive/folders/1GDncjYbLxKh8OcYmZ7R6h3Cv3pZqUCjc?usp=sha...

The tps will increase if I batch all the jobs together, but it will cause stuttering. As I mentioned in the "possible improvements", using IJob directly for each chunk is likely the solution.

Developer (1 edit)

May I know why do you think spamming keys when opening the program will make it less likely to happen?  Perhaps you have an idea what causes the issue?

Submitted(+1)

Ah, figured it out. It’s the edge panning feature that made it move, I just didn’t notice the mouse was at the edge of the screen when the game opened.