# HG changeset patch # User Eugen Sawin # Date 1310943064 -7200 # Node ID a131769728f1da75323bc99b7dc8d73c793115c3 # Parent 808a8eb53a60963e8ec7773b50896f5939bd2ffa Added header. diff -r 808a8eb53a60 -r a131769728f1 cau/automat.py --- a/cau/automat.py Sun Jan 09 16:23:29 2011 +0100 +++ b/cau/automat.py Mon Jul 18 00:51:04 2011 +0200 @@ -1,3 +1,8 @@ +""" +Description: Cellular automaton server. +Author: Eugen Sawin +""" + import sys import math import rules @@ -15,9 +20,7 @@ def main(rule, iterations, dumpfile): grid = Grid() for pos, value in configs[type(rule)]: - grid.set(pos, value) - - + grid.set(pos, value) last_pi = 3.0 for i in range(iterations): A = len(grid) @@ -28,7 +31,7 @@ pi = (pi + last_pi) / 2.0 last_pi = pi print "%i %f(%f) %i(%i) %f" % (i, r, r - r_ideal, - A, A - A_ideal, pi) + A, A - A_ideal, pi) grid = rule.iterate(grid) if dumpfile: marshal.dumpGrid(grid, dumpfile) diff -r 808a8eb53a60 -r a131769728f1 cau/grid.py --- a/cau/grid.py Sun Jan 09 16:23:29 2011 +0100 +++ b/cau/grid.py Mon Jul 18 00:51:04 2011 +0200 @@ -1,5 +1,9 @@ +""" +Description: Cellular automata grid. +Author: Eugen Sawin +""" + class Grid(object): - def __init__(self): self.cells = {} self.valuemap = {} diff -r 808a8eb53a60 -r a131769728f1 cau/gridmarshal.py --- a/cau/gridmarshal.py Sun Jan 09 16:23:29 2011 +0100 +++ b/cau/gridmarshal.py Mon Jul 18 00:51:04 2011 +0200 @@ -1,3 +1,8 @@ +""" +Description: Grid configuration parser. +Author: Eugen Sawin +""" + import ConfigParser from grid import Grid diff -r 808a8eb53a60 -r a131769728f1 cau/render.py --- a/cau/render.py Sun Jan 09 16:23:29 2011 +0100 +++ b/cau/render.py Mon Jul 18 00:51:04 2011 +0200 @@ -1,3 +1,8 @@ +""" +Description: Renderer for grid configuration based on Tkinter. +Author: Eugen Sawin +""" + import Tkinter as tk from grid import Grid diff -r 808a8eb53a60 -r a131769728f1 cau/rules.py --- a/cau/rules.py Sun Jan 09 16:23:29 2011 +0100 +++ b/cau/rules.py Mon Jul 18 00:51:04 2011 +0200 @@ -1,8 +1,12 @@ +""" +Description: Circular cellular growth rules. +Author: Eugen Sawin +""" + import copy from grid import Grid class Rule1(object): - def iterate(self, oldgrid): grid = copy.deepcopy(oldgrid) for x in xrange(oldgrid.minx - 1, oldgrid.maxx + 2): @@ -25,7 +29,6 @@ class Rule2(object): - def iterate(self, oldgrid): grid = copy.deepcopy(oldgrid) for x in xrange(oldgrid.minx - 1, oldgrid.maxx + 2): @@ -38,8 +41,7 @@ import random import marshal -class PotentialGrowth(object): - +class PotentialGrowth(object): def __init__(self): random.seed() self.potential = 4 # values 4-8 are viable diff -r 808a8eb53a60 -r a131769728f1 server.py --- a/server.py Sun Jan 09 16:23:29 2011 +0100 +++ b/server.py Mon Jul 18 00:51:04 2011 +0200 @@ -1,7 +1,7 @@ #!/usr/bin/python import com -import grid +#import grid import optparse import SocketServer