Parallel Implementation
In this stage, you are required to write code to evolve Game of Life using multiple worker goroutines on a single machine.
The following pages are some suggested steps to help you get started, you are not required to follow them.
Your implementation will be marked against the success criteria outlined here.
Step 6
Implement logic to visualise the state of the game using SDL.
You will need to utilise CellFlipped
and TurnComplete
events to achieve this.
Send TurnComplete
events at the end of each turn, even if you are about to send FinalTurnComplete
.
Send CellFlipped
events whenever a cell changes from alive to dead or from dead to alive.
Don't forget to send
CellFlipped
events for every initially alive cell before the firstStateChange
is sent.
Check out gol/event.go
and sdl/loop.go
for more details.
NOTE: You can collect many flipped cells and send a
CellsFlipped
event with all of them instead of sendingCellFlipped
for every flipped cell. You can send more than oneCellsFlipped
event in a turn, i.e., each worker could sendCellsFlipped
. Be careful not to send bothCellFlipped
andCellsFlipped
events for the same cell, or you will flip it twice
Test
To test the visualisation and control rules, type the following in the terminal.
go test -v -run TestSdl -sdl
go test -v -run TestSdl
You can also run the program and view the visualisation by typing the following in the terminal.
go run .
Finally, type the following in the terminal to make sure all tests are passing with race detector.
go test -v -race