Better circle approximation rule.
1.1 --- a/caumat.py Thu Dec 30 14:22:05 2010 +0100
1.2 +++ b/caumat.py Thu Dec 30 14:36:25 2010 +0100
1.3 @@ -55,12 +55,14 @@
1.4 return grid
1.5
1.6 def grow(self, grid, (x, y)):
1.7 - neighbours = [(x-1, y), (x, y+1), (x+1, y), (x, y-1)]
1.8 + n1 = [(x-1, y), (x, y+1), (x+1, y), (x, y-1)]
1.9 + n2 = [(x+1, y+1), (x+1, y-1), (x-1, y-1), (x-1, y+1)]
1.10 + neighbours = random.choice((n1, n1, n2))
1.11 neighbours = [n for n in neighbours if n not in grid.cells]
1.12 - try:
1.13 + if len(neighbours):
1.14 pos = random.choice(neighbours)
1.15 value = 4
1.16 - except IndexError:
1.17 + else:
1.18 pos = (x, y)
1.19 value = grid.cells[pos]
1.20 return pos, value