summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-10-06 13:31:47 +0200
committerGuillaume Seguin <guillaume@segu.in>2007-10-06 13:31:47 +0200
commit782ae1a1aa1f6b49a65a0ad24c50b8243b76d4e2 (patch)
treed41f8da9eebe0089d72d5d2842862c06eb0dae8f
parent800bc37c33b6f4e0b375e3e44f6371fb02637c43 (diff)
downloadgol-782ae1a1aa1f6b49a65a0ad24c50b8243b76d4e2.tar.gz
gol-782ae1a1aa1f6b49a65a0ad24c50b8243b76d4e2.tar.bz2
* Beautify
-rwxr-xr-xjdlv.py30
1 files changed, 6 insertions, 24 deletions
diff --git a/jdlv.py b/jdlv.py
index fc8b0e5..202e03c 100755
--- a/jdlv.py
+++ b/jdlv.py
@@ -125,30 +125,12 @@ class gtkGameOfLife (gtk.DrawingArea):
jplusone = (j + 1) % self._size
iminusone = (i - 1 + self._size) % self._size
jminusone = (j - 1 + self._size) % self._size
- # i + 1, j + 1
- if self._map[iplusone][jplusone]:
- surrounding += 1
- # i, j + 1
- if self._map[i][jplusone]:
- surrounding += 1
- # i + 1, j
- if self._map[iplusone][j]:
- surrounding += 1
- # i - 1, j - 1
- if self._map[iminusone][jminusone]:
- surrounding += 1
- # i - 1, j
- if self._map[iminusone][j]:
- surrounding += 1
- # i - 1, j + 1
- if self._map[iminusone][jplusone]:
- surrounding += 1
- # i, j - 1
- if self._map[i][jminusone]:
- surrounding += 1
- # i + 1, j - 1
- if self._map[iplusone][jminusone]:
- surrounding += 1
+ for x in range (-1, 2):
+ i2 = (i + x + self._size) % self._size
+ for y in range (-1, 2):
+ j2 = (j + y + self._size) % self._size
+ if self._map[i2][j2]:
+ surrounding += 1
return surrounding
def update_map (self):