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
sis pressed, save the current state of the board as a PGM image.NOTE: Don't forget to send an
ImageOutputCompleteevent after a PGM image is saved. - If
qis 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
qis pressed:Complete the current turn
Send aFinalTurnCompleteevent
Save the final state as PGM image and send anImageOutputCompleteevent
Send aStateChangeevent and terminate - If
pis pressed, pause the processing and send aStateChangeevent.
Whenpis pressed again, resume the processing and send aStateChangeevent.NOTE: It is necessary for
qandsto work while the execution is paused.
Test
To test the visualisation and control rules, type the following in the terminal.
go test ./tests -v -run TestKeyboard -sdlgo test ./tests -v -run TestKeyboardYou can also run the program and test the control rules manually by typing the following in the terminal.
go run .