Embed
Email

life_gauss

Document Sample

Shared by: liamei12345
Categories
Tags
Stats
views:
0
posted:
10/22/2011
language:
English
pages:
21
The Game of Life

• A simulation of "life". From simple rules,

complex behavior arises

Rules

– A cell that is alive and has fewer than two live

neighbors dies (because of loneliness)

– A cell that is alive and has more than 3 live

neighbors dies (because of over-crowding)

– A cell that is dead and has exactly 3 live

neighbors comes to life

– All other cells maintain their state

The Game of Life: History





• Created by John Horton Conway,

a British Mathematician

• Inspired by a problem presented

by John Von Neumann:

– Build a hypothetical machine that can

build copies of itself





• First presented in 1970, Scientific American

“Life”

John Conway

Grid World

red cells are alive

Evolutionary rules

• Everything depends on a cell’s

eight neighbors

• Exactly 3 neighbors give birth

to a new, live cell!

• Exactly 2 or 3 neighbors keep an

existing cell alive

• Any other number of neighbors kill

the central cell (or keep it dead)





white cells are empty

Life

Grid World

red cells are alive

Evolutionary rules

• Everything depends on a cell’s

eight neighbors

• Exactly 3 neighbors give birth

to a new, live cell!

• Exactly 2 or 3 neighbors keep an

existing cell alive

• Any other number of neighbors kill

the central cell (or keep it dead)





white cells are empty

Life

Grid World

red cells are alive

Evolutionary rules

• Everything depends on a cell’s

eight neighbors

• Exactly 3 neighbors give birth

to a new, live cell!

• Exactly 2 or 3 neighbors keep an

existing cell alive

• Any other number of neighbors kill

the central cell (or keep it dead)





white cells are empty

Life

Grid World

red cells are alive

Evolutionary rules

• Everything depends on a cell’s

eight neighbors

• Exactly 3 neighbors give birth

to a new, live cell!

• Exactly 2 or 3 neighbors keep an

existing cell alive

• Any other number of neighbors kill

the central cell (or keep it dead)



Keep going!

white cells are empty

life out there...

Creating Life

updateNextLife(oldB, newB)

old generation or "board" new generation or "board"





0 1 2 3 4 5 0 1 2 3 4 5



0 0





1 1





2 2





3 3





4 4





5 5

Creating Life

updateNextLife(oldB, newB)

old generation or "board" new generation or "board"



0 1 2 3 4 5 0 1 2 3 4 5



0 0





1 1





2 2





3 3





4 4





5 5

Details

updateNextLife(oldB, newB)

old generation or "board" new generation or "board"







For each generation…

• 0 represents an empty cell

• 1 represents a living cell

• outermost edge should

always be left empty (even

if there are 3 neighbors)

• compute all cells based on

their previous neighbors



http://www.math.com/students/wonders/life/life.html

life out there...

Main Loop

def life( width, height ):

""" will become John Conway's Game of Life... """

B = createBoard(width, height)

csplot.showAndClickInIdle(B)

while True: # run forever

csplot.show(B) # show current B

time.sleep(0.25) # pause a bit

oldB = B

B = createBoard( width, height )

updateNextLife( oldB, B ) # gets a new board

Main Loop

def life( width, height ):

""" will become John Conway's Game of Life... """

B = createBoard(width, height)

csplot.showAndClickInIdle(B)

while True: # run forever

csplot.show(B) # show current B

time.sleep(0.25) # pause a bit

oldB = B

B = createBoard( width, height )

updateNextLife( oldB, B ) # gets a new board



Update MUTATES the list B

Why not just have update RETURN a new list?

(i.e., why bother with mutation at all?)

to  and beyond!



• Are there stable life configurations? "rocks"









• Are there oscillating life configurations? "plants"

period 3





period 2







• Are there self-propagating life configurations? "animals"

to  and beyond!



• Are there life configurations that expand forever?





• What is the largest amount of the life

universe that can be filled with cells?





• Are all feasible configurations reachable?





• How sophisticated can the structures

in the life universe be?



http://www.ibiblio.org/lifepatterns/

Gaussian Elimination

2p + 3n + -1q = -8.00

-3p + -1n + 2q = 42.00

1p + -9n + 4q = 56.00





• get 1s along the diagonal

Goal: Find p,n,q

• get 0s elsewhere on the left



1p + 0n + 0q = 1.00

0p + 1n + 0q = 5.00

0p + 0n + 1q = 25.00





Using only row operations (our methods) !



Just the array is necessary !

We can get rid of the variables...

where to start?

Solve

1.00 1.50 -0.50 -4.00

-3.00 -1.00 2.00 42.00 multiply Row 0 by 0.5

1.00 -9.00 4.00 56.00



1.00 1.50 -0.50 -4.00

0.00 3.50 0.50 30.00 add 3 times Row 0 to Row 1

0.00 -10.50 4.50 44.00 add -1 times Row 0 to Row 2





1.00 0.00 -0.71 -16.85 multiply Row 1 by 1/3.5

0.00 1.00 0.14 30.00 add a multiple of Row 1 to Row 0

0.00 0.00 6.00 150.00 add a multiple of Row 1 to Row 2







1.00 0.00 0.00 1.00

0.00 1.00 0.00 5.00 same for other columns

as far as possible...

0.00 0.00 1.00 25.00

A before

two of row 1

are to be row 0 0.00 1.00 0.00 1.00

Write a method that added to row 2 row 1 3.00 0.50 0.50 3.00

adds two times the

values in row #1 into row 2 10.00 20.00 30.00 40.00

the values in row #2. Only row 2's

values change. row 0 0.00 1.00 0.00 1.00

You may assume that A

row 1 3.00 0.50 0.50 3.00

has at least three rows!

The values in row 1

should not change

row 2 16.00 21.00 31.00 46.00



A after



def add2ofRow1IntoRow2( A ):









How could you make the source and

destination rows inputs to this function?



How would it change the code?

Write a method that

adds row #s into the row 0 0.00 1.00 0.00 1.00

values in row #d. s row 1 3.00 0.50 0.50 3.00

d row 2 10.00 20.00 30.00 40.00

row 0 0.00 1.00 0.00 1.00

s row 1 3.00 0.50 0.50 3.00

d row 2 16.00 21.00 31.00 46.00









def addRowSIntoRowD( rs, rd, A ):

Using 2d arrays

arr 2.00 3.00 -1.00 -8.00

-3.00 -1.00 2.00 42.00

Before 1.00 -9.00 4.00 56.00







arr 2.00 3.00 -3.00 -8.00

-3.00 -1.00 6.00 42.00

After 1.00 -9.00 12.00 56.00



A method for multiplying columns:

Solving ?!

2p + 3n + -1q = -8.00

Gaussian

-3p + -1n + 2q = 42.00

Elimination

1p + -9n + 4q = 56.00





• get 1s along the diagonal

Goal: Find p,n,q

• get 0s elsewhere on the left





1.00p + 1.50n + -0.50q = -4.00

-3.00p + -1.00n + 2.00q = 42.00 multiply the zeroth

1.00p + -9.00n + 4.00q = 56.00 row (R0) by 0.5







1.00p + 1.50n + -0.50q = -4.00 add 3 times R0 to R1

0.00p + 3.50n + 0.50q = 30.00 add -1 times R0 to R2

-0.00p + -10.50n + 4.50q = 44.00

Solved !

1.00p + 1.50n + -0.50q = -4.00

0.00p + 3.50n + 0.50q = 30.00 multiply R1 by 1 / 3.5

-0.00p + -10.50n + 4.50q = 44.00





1.00p + 1.50n + -0.50q = -4.00 add -1.5 times R1 to R0

0.00p + 1.00n + 0.14q = 8.57 add 10.5 times R1 to R2

-0.00p + -10.50n + 4.50q = 44.00





1.00p + 0.00n + -0.71q = -16.85 add 3 times R0 to R1

0.00p + 1.00n + 0.14q = 30.00 add -1 times R0 to R2

-0.00p + 0.00n + 6.00q = 150.00



continue...



1.00p + 0.00n + 0.00q = 1.00

0.00p + 1.00n + 0.00q = 5.00 only the array is

-0.00p + 0.00n + 1.00q = 25.00 necessary !

Solved !

1.00p + 1.50n + -0.50q = -4.00

0.00p + 3.50n + 0.50q = 30.00 multiply R1 by 1 / 3.5

-0.00p + -10.50n + 4.50q = 44.00





1.00p + 1.50n + -0.50q = -4.00 add -1.5 times R1 to R0

0.00p + 1.00n + 0.14q = 8.57 add 10.5 times R1 to R2

-0.00p + -10.50n + 4.50q = 44.00





1.00p + 0.00n + -0.71q = -16.85 add 3 times R0 to R1

0.00p + 1.00n + 0.14q = 30.00 add -1 times R0 to R2

-0.00p + 0.00n + 6.00q = 150.00



continue...



1.00p + 0.00n + 0.00q = 1.00

0.00p + 1.00n + 0.00q = 5.00 only the array is

-0.00p + 0.00n + 1.00q = 25.00 necessary !


Related docs
Other docs by liamei12345
of Approved Sensitivities _4-29-11_ - EIPC
Views: 0  |  Downloads: 0
02Test-Result-III-Web
Views: 2  |  Downloads: 0
Chicken Soup Poems
Views: 16  |  Downloads: 0
Kansas - Association of Women Psychiatrists
Views: 0  |  Downloads: 0
Selection 12
Views: 0  |  Downloads: 0
Lesson 6-Building a Directory Service
Views: 0  |  Downloads: 0
piacente_10_11
Views: 1  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!