Introduction Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.” Game of Life Our project: Finite grid of rectangles, 4 different topologies Infinite grid of hexagons
Introduction Rules of the Game: Any live cell with fewer than two live neighbors dies Any live cell with more than three live neighbors dies Any live cell with two or three live neighbors lives, unchanged, to the next generation. Any dead cell with exactly three live neighbors comes to life.
Entity Relationship Diagram: C:\Documents and Settings\Alicia\My Documents\Ryan's Stuff\Presentation\Presentation\pdfs\entity_rel ationship_diagram.pdf C:\Documents and Settings\Alicia\My Documents\Ryan's Stuff\Presentation\Presentation\pdfs\entity_rel ationship_diagram.pdf
Cell Selection Our numbering scheme: 1-indexed Single identifier instead of (x,y) coords.
Cell Selection Given (x,y), extract clicked cell by treating as row-major ordered matrix: M[ i ][ j ] = i * numOfColumns + j i = floor(y / cell-height) j = floor(x / cell-width)
Cell Selection How does this work with non-rectangular cells, specifically hexagonal cells? Rows and columns are staggered
Cell Selection Square Grid i = floor( y / cell-height ) j = floor( x / cell-width ) Hexagonal Grid i ≠ floor( y / cell-height ) j ≈ floor( x / cell-width ) Overlap has a cumulative effect as the rows increase Alternating rows are staggered
Cell Selection So we adjust the reported coordinates so that we can treat it like a grid of square cells: height = 2a + c y = y + (a * ceiling(y/height)) (row is odd)? x = x – b : x = x c b a
Statistical Plotting Part of target audience: tight-knit, online community extremely interested in mathematical analysis of patterns and outcomes of game Why not provide some mathematical tools to assist them and capture their interest? Life is a mathematical simulation, after all
Statistical Plotting As a result, we added the ability to create statistical plots of the simulations User can plot population vs. time Number of points limited to 100 because of performance concerns Plot can be created after all cells have died and/or after 100 timesteps have elapsed
Statistical Plotting
Generative Music Algorithmically-produced music Brian Eno mentioned possibility of using Life in connection with generative music in talk in San Francisco 1 “Generative Music”,
Generative Music Separate interface: 15 lines of code (defun draw-selected-cells (cells dimensions scene) (if (consp cells) (let* ((x-offset …) (row-number …) (new-scene …) (sound (play-wav (car (nthcdr (car cells) (nthcdr row-number *notes*))) t)) (draw-selected-cells (cdr cells) dimensions new-scene)) scene)) *notes* is essentially a two-dimensional lists of filenames (strings) corresponding to each note through 2 octaves
Generative Music Adding ability to choose gen. music option: 8 loc (interface) + 12 loc (mouse event handling) = 20 lines of code Filenames constant: 7 lines of code Miscellanea: 10 lines of code Total: 52 lines of code
Persistent Patterns (File I/O) A common file format utilized by many life programs for storing patterns already exists ASCII representations of the pattern are stored in a binary file with.lif extension
Persistent Patterns
≈ 50 lines of code 25 lines of code for input Method for iterating through list of bytes Method for formatting list of bytes into list of lists Method for constructing board setup based on specified pattern 25 lines of code for output Based on previous experience with Dr. Page’s I/O routines