diff --git a/examples/highlife.py b/examples/highlife.py new file mode 100644 index 0000000..04c9057 --- /dev/null +++ b/examples/highlife.py @@ -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) diff --git a/examples/life.py b/examples/life.py index 83edbb4..d522c0c 100644 --- a/examples/life.py +++ b/examples/life.py @@ -1,4 +1,5 @@ """ +B3/S34: Game of Life @author: jrpotter @date: June 01, 2015 diff --git a/examples/life_without_death.py b/examples/life_without_death.py new file mode 100644 index 0000000..8af58b3 --- /dev/null +++ b/examples/life_without_death.py @@ -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) diff --git a/examples/morley.py b/examples/morley.py new file mode 100644 index 0000000..6125046 --- /dev/null +++ b/examples/morley.py @@ -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) diff --git a/examples/replicator.py b/examples/replicator.py new file mode 100644 index 0000000..2b980f7 --- /dev/null +++ b/examples/replicator.py @@ -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) diff --git a/examples/seeds.py b/examples/seeds.py new file mode 100644 index 0000000..6fc3ab0 --- /dev/null +++ b/examples/seeds.py @@ -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)