Conway's Game of Life

john's Avatar

john

30 Oct, 2016 04:29 AM

UPDATE: New version attached in reply to this comment...

Attached is a proof of concept NodeBox network that generates an open-ended number of life patterns based on Conway's Game of Life. If you are not familiar with the game of life, see https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

Veteran NodeBoxers should be surprised to see this. NodeBox renders a stateless, deterministic output and has no way of modeling the open-ended growth needed to produce fractals, L-systems, space-filling curves, cellular automata, simulations, mazes, Conway's Game of Life, etc.

The trick that makes this possible is a very simple python node called write_csv that writes a list to a text file. By successively writing and reading (via a standard csv node), I can introduce a tiny bit of "state" into NodeBox's otherwise stateless world. It's a bit of a kludge, but this technique opens many new possibilities.

I am attaching a zipped folder containing the NodeBox network and some supporting files and examples. I also include another NodeBox network that turns any text string into a life pattern that can then be feed into the Conway.ndbx engine.

Some notes on the using the network:

In order to work correctly, the "Game of Life" folder must be placed on your desktop (see UPDATED version in next comment to remove this restriction). I have tested it on both a Mac and a PC.

The network includes some built-in starter patterns including a random cell generator and an option to import saved life patterns produced by the engine. To change the starting configuration just attach the desired node to the switch (comments included in network).

The file format is a simple one-column csv file containing the generation number (initially 1) and a series of 1s and 0s to represent each cell in the field.

You can change the value in the "field_size" node. A value of 50 will create a 50 x 50 field that wraps to form a torus. The cell size will adjust automatically to fill a 640 x 640 animation frame

All computations other than writing the temp file are done entirely in NodeBox. This version can generate and draw around 7 or 8 thousand cells per second; I'm sure this speed could be improved.

Click Play to start the life process. You can also export a movie in the usual way.

You can also click the frames field to increment two generations at a time. Two generations are created with each click because NodeBox issues two reloads for each click whether or not a frame node is present in the network (unless frame is set to 0 in which case it only generates one reload).

To save a generated pattern, pause the animation (giving it enough time to finish writing the file), then make a copy of the "conway.csv" temp file inside the Game of Life folder and rename it. Be sure to note the field size you used since you will have to set this manually if you ever import it back into the conway engine.

The write_csv node returns a text string that must be included in the output in order for the process to work. Including the text string forces NodeBox to render the write_csv node on each reload.

If the temp file becomes corrupted NodeBox may throw an error. If this happens delete conway.csv and then copy and rename the backup "conway copy.csv" file included in the folder.

Many improvements are possible. It would be fun to add color and render the cells in a more interesting and artful way using the power of NodeBox. If anyone does anything interesting with this, please post animations to the Show Your Work folder!

I am attaching the zipped folder, a screenshot, and several demo animations. A 3800-generation animation is included in the folder.

Enjoy!

  1. Support Staff 1 Posted by john on 23 Nov, 2019 11:00 PM

    john's Avatar

    UPDATE

    Attached is an updated version of Game of Life that uses my write_table node. All is as it was, except now you no longer need to leave the Game of Life folder on your desktop.

    You're welcome!

    John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Life_Screenshot.png 127 KB
  • Game_of_Life.zip 7.92 MB
  • NodeBox600.mp4 1.38 MB
  • acorn1500grid50.mp4 1.72 MB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

09 Dec, 2019 01:36 PM
09 Dec, 2019 12:37 AM
07 Dec, 2019 09:56 AM
05 Dec, 2019 07:05 AM
05 Dec, 2019 06:21 AM

 

26 Nov, 2019 08:05 PM
26 Nov, 2019 08:36 AM
26 Nov, 2019 08:33 AM
25 Nov, 2019 10:44 PM
25 Nov, 2019 06:06 PM
23 Nov, 2019 11:00 PM