The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Camal (16) [Avatar] Offline
I just finished my implementation “Game of Life” in Go. I would love to get some feedback for my written test and approach to it.

Rules :

* A living (`true`) cell with less then 2 living neighbours will die
* A living (`true`) cell with 2 or 3 living neighbours will live
* A dead (`false`) cell with 3 living neighbours will live

I was really lost at line because I was swapping the universes within the function.

Also I really would like a cool animation. The only solution I found was to but this is removing everything, even the prompt.

I was a little messy in the test department but I tried to move my mock into a helper function.

Thanks for any thoughts on this one smilie
Nathan Youngman (56) [Avatar] Offline
Good on you for writing tests -- especially since testing isn't covered in this book.

One thing to watch for is always indexing the universe in the same way. I think this line


should be:


If that's a bug, maybe your tests don't have the right expectations?

One other recommendation is to simplify your Alive method. Try to implement it without using any if statements.

Thanks for posting your solution,