Added examples
parent
daf1b0437c
commit
26af992567
|
@ -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)
|
|
@ -1,4 +1,5 @@
|
|||
"""
|
||||
B3/S34: Game of Life
|
||||
|
||||
@author: jrpotter
|
||||
@date: June 01, 2015
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
Loading…
Reference in New Issue