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 5
Implement the following control rules. Note that the running SDL provides you with a channel containing the relevant keypresses.
- If
s
is pressed, save the current state of the board as a PGM image.NOTE: Don't forget to send an
ImageOutputComplete
event after a PGM image is saved. - If
q
is pressed, stop executing Gol computation, save the current state of the board as a PGM image, then terminate the program.NOTE: Your distributor should behave as following after
q
is pressed:Complete the current turn
Send aFinalTurnComplete
event
Save the final state as PGM image and send anImageOutputComplete
event
Send aStateChange
event and terminate - If
p
is pressed, pause the processing and send aStateChange
event.
Whenp
is pressed again, resume the processing and send aStateChange
event.NOTE: It is necessary for
q
ands
to work while the execution is paused.
Test
To test the visualisation and control rules, type the following in the terminal.
go test -v -run TestKeyboard -sdl
go test -v -run TestKeyboard
You can also run the program and test the control rules manually by typing the following in the terminal.
go run .