Mercurial > public > think_complexity
comparison ch7ex2.py @ 48:98eb01502cf5 tip
Follow up to last commit. Re-orient the r-pentomino. Added progress display.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 31 Jul 2013 20:37:12 -0500 |
parents | 2b0e229e163c |
children |
comparison
equal
deleted
inserted
replaced
47:2b0e229e163c | 48:98eb01502cf5 |
---|---|
9 | 9 |
10 | 10 |
11 class RPentomino(Life.Life): | 11 class RPentomino(Life.Life): |
12 | 12 |
13 def __init__(self, n): | 13 def __init__(self, n): |
14 super(RPentomino, self).__init__(n, mode='constant', cval=0, random=False) | 14 super(RPentomino, self).__init__(n, mode='constant', cval=0, |
15 random=False, show_progress=10) | |
15 | 16 |
16 i, j = n / 2, n / 2 | 17 i, j = n / 2, n / 2 |
17 self.array[i, j] = 1 | 18 self.array[i, j] = 1 |
18 self.array[i, j - 1] = 1 | 19 self.array[i, j - 1] = 1 |
19 self.array[i, j + 1] = 1 | 20 self.array[i + 1, j] = 1 |
21 self.array[i + 1, j + 1] = 1 | |
20 self.array[i - 1, j] = 1 | 22 self.array[i - 1, j] = 1 |
21 self.array[i + 1, j - 1] = 1 | 23 |
22 | 24 |
23 if __name__ == '__main__': | 25 if __name__ == '__main__': |
24 life = RPentomino(150) | 26 life = RPentomino(150) |
25 viewer = Life.LifeViewer(life, delay=1) | 27 viewer = Life.LifeViewer(life, delay=1) |
26 viewer.animate(steps=1200) | 28 viewer.animate(steps=1200) |