22
Introduction Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.” Our project: Finite grid of rectangles, 4 different topologies Infinite grid of hexagons

Introduction Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Embed Size (px)

Citation preview

Page 1: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Introduction Per the project description: “Conway's

Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Our project: Finite grid of rectangles, 4 different topologies Infinite grid of hexagons

Page 2: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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.

Page 3: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Entity Relationship Diagram: C:\Documents and Settings\Alicia\My Documen

ts\Ryan's Stuff\Presentation\Presentation\pdfs\entity_relationship_diagram.pdf

Page 4: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”
Page 5: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Cell Selection

Our numbering scheme:

1-indexed

Single identifier instead of (x,y) coords.

Page 6: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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)

Page 7: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Cell Selection

How does this work with non-rectangular cells, specifically hexagonal cells? Rows and columns are

staggered

Page 8: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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

Page 9: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Cell Selection

So we adjust the reportedcoordinates so that we can

treatit like a grid of square cells:

height = 2a + cy = y + (a *

ceiling(y/height))

(row is odd)? x = x – b : x = x

c

b

a

Page 10: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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

Page 11: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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

Page 12: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Statistical Plotting

Page 13: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”
Page 14: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”
Page 15: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”
Page 16: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”
Page 17: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Generative Music

Algorithmically-produced music

Brian Eno mentioned possibility of using Life in connection with generative music in talk in San Francisco1

“Generative Music”, http://www.inmotionmagazine.com/eno1.html

Page 18: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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

Page 19: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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

Page 20: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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

Page 21: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

Persistent Patterns

Page 22: Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”

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