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
CellFlippedevents for every initially alive cell before the firstStateChangeis sent.
Check out gol/event.go and sdl/loop.go for more details.
NOTE: You can collect many flipped cells and send a
CellsFlippedevent with all of them instead of sendingCellFlippedfor every flipped cell. You can send more than oneCellsFlippedevent in a turn, i.e., each worker could sendCellsFlipped. Be careful not to send bothCellFlippedandCellsFlippedevents 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 ./tests -v -run TestSdl -sdlgo test ./tests -v -run TestSdlYou 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 ./tests -v -race