Brian's Brain as a brain-teaser...

Was just playing around with implementing "Brian's Brain" in Numpy/Pygame it's a "life" style automata where there are just 3 rules:

  • if cell is dying, cell dies
  • if cell is alive, cell starts dying
  • if cell is dead and > 2 neighbours are on, cell becomes alive

there was a post about doing this in Clojure which had the nice side-effect of making the whole thing run in parallel.  I mistakenly started out thinking that numpy had data-parallel vector operations... oops.  Guess that's not there (yet?)  Anyway, the code is hacked together very quickly, you can play with it here:

bzr branch http://www.vrplumber.com/bzr/briansbrain

Click to restart with a new random data-set, Alt-F4 to exit.  The code to calculate the "neighbours" (effectively a rolling sum/window of the 8 cells adjacent to each cell) wound up far less efficient than I'd originally planned.  Originally I was mutating the one array in-place and basically running it in a trail around the core cell, but that wasn't at all clear looking in the code.

Anyway, not at all what I was needing to get done this evening, but there it is.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.