r
/
fifth
1
Fork 0

Added examples

master
Joshua Potter 2015-06-02 17:30:22 -04:00
parent daf1b0437c
commit 26af992567
6 changed files with 168 additions and 0 deletions

35
examples/highlife.py Normal file
View File

@ -0,0 +1,35 @@
"""
B368/S23: High Life
@author: jrpotter
@date: June 02, 2015
"""
if __name__ == '__main__':
import os, sys
sys.path.append(os.path.abspath('src'))
import cam
import ruleset as rs
def high_life(f_index, f_grid, indices, states, *args):
total = sum(f_grid[indices])
if not f_grid[f_index]:
if total == 3 or total == 6 or total == 8:
return rs.Configuration.OFF
else:
if total == 2 or total == 3:
return rs.Configuration.ON
return rs.Configuration.OFF
c = cam.CAM(1, 100, 2)
c.randomize()
r = rs.Ruleset(rs.Ruleset.Method.SATISFY)
offsets = rs.Configuration.moore(c.master)
r.addConfiguration(c.master, high_life, offsets)
c.start_plot(100, r, lambda *args: True)

View File

@ -1,4 +1,5 @@
""" """
B3/S34: Game of Life
@author: jrpotter @author: jrpotter
@date: June 01, 2015 @date: June 01, 2015

View File

@ -0,0 +1,31 @@
"""
B3/S012345678: Life Without Death
@author: jrpotter
@date: June 02, 2015
"""
if __name__ == '__main__':
import os, sys
sys.path.append(os.path.abspath('src'))
import cam
import ruleset as rs
def lwd(f_index, f_grid, indices, states, *args):
total = sum(f_grid[indices])
if not f_grid[f_index] and total == 3:
return rs.Configuration.ON
else:
return f_grid[f_index]
c = cam.CAM(1, 100, 2)
c.randomize()
r = rs.Ruleset(rs.Ruleset.Method.SATISFY)
offsets = rs.Configuration.moore(c.master)
r.addConfiguration(c.master, lwd, offsets)
c.start_plot(100, r, lambda *args: True)

35
examples/morley.py Normal file
View File

@ -0,0 +1,35 @@
"""
B368/S245: Morley
@author: jrpotter
@date: June 02, 2015
"""
if __name__ == '__main__':
import os, sys
sys.path.append(os.path.abspath('src'))
import cam
import ruleset as rs
def morley(f_index, f_grid, indices, states, *args):
total = sum(f_grid[indices])
if not f_grid[f_index]:
if total == 3 or total == 6 or total == 8:
return rs.Configuration.ON
else:
if total == 2 or total == 4 or total == 5:
return rs.Configuration.ON
return rs.Configuration.OFF
c = cam.CAM(1, 100, 2)
c.randomize()
r = rs.Ruleset(rs.Ruleset.Method.SATISFY)
offsets = rs.Configuration.moore(c.master)
r.addConfiguration(c.master, morley, offsets)
c.start_plot(100, r, lambda *args: True)

35
examples/replicator.py Normal file
View File

@ -0,0 +1,35 @@
"""
B1357/S1357: Replicator
@author: jrpotter
@date: June 02, 2015
"""
if __name__ == '__main__':
import os, sys
sys.path.append(os.path.abspath('src'))
import cam
import ruleset as rs
def replicator(f_index, f_grid, indices, states, *args):
total = sum(f_grid[indices])
if not f_grid[f_index]:
if total % 2 == 1:
return rs.Configuration.ON
else:
if total % 2 == 1:
return rs.Configuration.ON
return rs.Configuration.OFF
c = cam.CAM(1, 100, 2)
c.master[49:51, 49:51] = rs.Configuration.ON
r = rs.Ruleset(rs.Ruleset.Method.SATISFY)
offsets = rs.Configuration.moore(c.master)
r.addConfiguration(c.master, replicator, offsets)
c.start_plot(100, r, lambda *args: True)

31
examples/seeds.py Normal file
View File

@ -0,0 +1,31 @@
"""
B2/S: Seeds
@author: jrpotter
@date: June 02, 2015
"""
if __name__ == '__main__':
import os, sys
sys.path.append(os.path.abspath('src'))
import cam
import ruleset as rs
def seeds(f_index, f_grid, indices, states, *args):
total = sum(f_grid[indices])
if not f_grid[f_index] and total == 2:
return rs.Configuration.ON
else:
return rs.Configuration.OFF
c = cam.CAM(1, 100, 2)
c.randomize()
r = rs.Ruleset(rs.Ruleset.Method.SATISFY)
offsets = rs.Configuration.moore(c.master)
r.addConfiguration(c.master, seeds, offsets)
c.start_plot(100, r, lambda *args: True)