Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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.” Game of Life  Our project: Finite grid of rectangles, 4 different topologies Infinite grid of hexagons

2 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.

3  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

4

5 Cell Selection  Our numbering scheme: 1-indexed Single identifier instead of (x,y) coords.

6 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)

7 Cell Selection  How does this work with non-rectangular cells, specifically hexagonal cells? Rows and columns are staggered

8 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

9 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

10 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

11 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

12 Statistical Plotting

13

14

15

16

17 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”, http://www.inmotionmagazine.com/eno1.htmlhttp://www.inmotionmagazine.com/eno1.html

18 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

19 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

20 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

21 Persistent Patterns

22  ≈ 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


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

Similar presentations


Ads by Google