Best Pi approximation so far.
1.1 --- a/caumat.py Thu Dec 30 15:19:36 2010 +0100
1.2 +++ b/caumat.py Thu Dec 30 15:56:07 2010 +0100
1.3 @@ -62,7 +62,10 @@
1.4 def grow(self, grid, (x, y)):
1.5 n1 = [(x-1, y), (x, y+1), (x+1, y), (x, y-1)]
1.6 n2 = [(x+1, y+1), (x+1, y-1), (x-1, y-1), (x-1, y+1)]
1.7 - neighbours = random.choice((n1, n1, n1, n1, n1, n1, n2, n2, n2))
1.8 + c0 = (n1, )
1.9 + c1 = (n1, n2)
1.10 + c2 = (n1, n1, n2)
1.11 + neighbours = random.choice(random.choice((c0, c1, c2)))
1.12 neighbours = [n for n in neighbours if n not in grid.cells]
1.13 if len(neighbours):
1.14 pos = random.choice(neighbours)
2.1 --- a/caurender.py Thu Dec 30 15:19:36 2010 +0100
2.2 +++ b/caurender.py Thu Dec 30 15:56:07 2010 +0100
2.3 @@ -31,15 +31,18 @@
2.4 def main():
2.5 filename = sys.argv[1]
2.6 print "rendering ", filename
2.7 - render = Render("hope", 800, 800)
2.8 + render = Render("hope", 1000, 1000)
2.9 mod_time = 0
2.10 while True:
2.11 current = os.stat(filename)[stat.ST_MTIME]
2.12 if current > mod_time:
2.13 mod_time = current
2.14 print "updating render"
2.15 - grid = marshal.loadGrid(filename)
2.16 - render.render(grid)
2.17 + try:
2.18 + grid = marshal.loadGrid(filename)
2.19 + render.render(grid)
2.20 + except IndexError, ValueError:
2.21 + print "loading error"
2.22 time.sleep(1)
2.23
2.24 if __name__ == "__main__":