top | item 3876522

A Readable Conway's Game of Life

39 points| gsabo | 14 years ago |blog.gsabo.com | reply

17 comments

order
[+] ihodes|14 years ago|reply
Very cool, and nice code. Just to be pedantic (I mean it in the best way), this isn't quite literate programming.

A very basic explanation would be: literate programming is the result of writing a program in a sort of psuedo-code that explains the program in the order of the programmer's thoughts, and then running it through a compiler of sorts which "untangles" the literate program and outputs machine-readable code.

The linked post is nicely formatted and well-documented "regular" code.

[+] gsabo|14 years ago|reply
Thanks for pointing that out! I had assumed that Literate Programming was simply any programming with a focus on human readability. I've changed the title of the post and credited you at the bottom.
[+] agentultra|14 years ago|reply
The simplest version (and by my yard-stick is the de-facto measure of "readability") I've seen was at Pycon 2012 (http://azd325.github.com/Python/2012/03/23/pycon-2012-stop-w... around 17:30). The main take away that is demonstrated is that classes aren't necessary to write this program but it's the first thing most programmers reach for when implementing it.

Another thing I find a lot these days are an abundance of comments that explain what the code already explains. Some of the comments are good in this example, but many of them explain what I would know if I just read the code.

However, I do like the use of color! A great demonstration. Good work. :)

[+] gsabo|14 years ago|reply
I took your comment to heart and removed most of the comments in the source. I found the video inspiring (and infuriating) - just more proof that I'm a long way from unlearning my OO design tendencies. To start, I made the Neighborhood class a function instead. Thanks for sharing.
[+] wollw|14 years ago|reply
I've been working on a sculpture project[1] based on cellular automaton for the past two semesters. It's not exactly conway's game of life as I'm mostly focused on polygonal cells. Hardware wise it's mostly just LEDs with shift registers and an ATtiny85 but the code[2] might be interesting to some, in particular dealing with figuring out what cells are and aren't neighbors when you have an ambiguous layout. I've also put together an Android simulator[3] I use for exploring ideas that defines designs using JSON but I've put a lot less work into it.

[1] http://wollw.github.com/automaton-avr/

[2] https://github.com/Wollw/Cellular-Polymaton

[3] https://github.com/Wollw/Polymaton

[+] jastanton_|14 years ago|reply
Oh what the heck, because we're all sharing our Conways Attempts here is mine: https://github.com/JAStanton/conways-game-of-life

And the live version: http://www.jastanton.com/experiments/conways-game-of-life/

Mine acts more like a game, you can start and stop with 's' and enter draw mode with 'd' and draw on the cells.

[+] gsabo|14 years ago|reply
The logical simplicity of the rules makes it impossible to resist implementation, it seems :) I love being able to draw on your version - I missed out on implementing drag events.

I notice that you separate your "views" (this.cells) from your "models" (this.grid). This seems like a good idea from an MVC perspective, but I would worry that I'm forgetting to keep them in-sync in all cases.

[+] huhtenberg|14 years ago|reply
Another idea for colors is to use progressively more transparent pixels for older generations. Add a bit of a hue shift and it renders some really beautiful decay visualizations.
[+] dethstarr|14 years ago|reply
Good job. I enjoyed looking at the output from an artistic point of view.