Moved cau to cau.
6 def iterate(self, oldgrid):
7 grid = copy.deepcopy(oldgrid)
8 for x in xrange(oldgrid.minx - 1, oldgrid.maxx + 2):
9 for y in xrange(oldgrid.miny - 1, oldgrid.maxy + 2):
10 #print x, y, self.neighbours(oldgrid, x, y)
11 n = self.neighbours(oldgrid, (x, y))
16 def neighbours(self, grid, (testx, testy)):
18 #print "testing ", testx, testy
19 for x in range(testx - 1, testx + 2):
20 for y in range(testy - 1, testy + 2):
21 if (x, y) in grid.cells:
29 def iterate(self, oldgrid):
30 grid = copy.deepcopy(oldgrid)
31 for x in xrange(oldgrid.minx - 1, oldgrid.maxx + 2):
32 for y in xrange(oldgrid.miny, oldgrid.maxy + 2):
33 #print "testing ", x, y,
34 if (x+1, y) in oldgrid.cells or (x, y-1) in oldgrid.cells:
41 class PotentialGrowth(object):
46 def iterate(self, oldgrid):
50 if i in oldgrid.valuemap:
51 value_pos[i] = copy.deepcopy(oldgrid.valuemap[i])
53 if i in oldgrid.valuemap:
54 for cell in value_pos[i]:
57 new_pos, new_value = self.grow(grid, pos)
58 grid.set(new_pos, new_value)
59 grid.set(pos, value - 1)
62 def grow(self, grid, (x, y)):
63 n1 = [(x-1, y), (x, y+1), (x+1, y), (x, y-1)]
64 n2 = [(x+1, y+1), (x+1, y-1), (x-1, y-1), (x-1, y+1)]
68 neighbours = random.choice(random.choice((c0, c1, c2)))
69 neighbours = [n for n in neighbours if n not in grid.cells]
71 pos = random.choice(neighbours)
75 value = grid.cells[pos]