- commit
- f42be35e4fd9e1421c1992aa1ffb2b36812cf166
- parent
- 549e2e6f6540c19a00c30b4981f3564cfa67bf27
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2014-05-25 20:12
drop unused options from neighbors()
Diffstat
| M | DEATH/matrix.py | 24 | +++++------------------- |
1 files changed, 5 insertions, 19 deletions
diff --git a/DEATH/matrix.py b/DEATH/matrix.py
@@ -66,37 +66,23 @@ class Map(Matrix): 66 66 def clear(self, i, j): 67 67 self.setitem(i, j, -1) 68 6869 -1 def neighbors(self, players, reverse=False):70 -1 try:71 -1 0 in players72 -1 except:73 -1 players = [players]74 -1 if reverse:75 -1 players.append(self.value)-1 69 def neighbors(self, players): 76 70 result = Map(self.rows, self.cols, self.diagonal) 77 71 for i in range(self.rows): 78 72 for j in range(self.cols): 79 73 a = 0 80 74 for cood in [(i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)]: 81 75 try:82 -1 if reverse:83 -1 if self.getitem(cood[0], cood[1]) not in players:84 -1 a += 185 -1 else:86 -1 if self.getitem(cood[0], cood[1]) in players:87 -1 a += 1-1 76 if self.getitem(cood[0], cood[1]) in players: -1 77 a += 1 88 78 except: 89 79 pass 90 80 if self.diagonal: 91 81 for cood in [(i + 1, j + 1), (i + 1, j - 1), (i - 1, j + 1), 92 82 (i - 1, j - 1)]: 93 83 try:94 -1 if reverse:95 -1 if self.getitem(cood[0], cood[1]) not in players:96 -1 a += 197 -1 else:98 -1 if self.getitem(cood[0], cood[1]) in players:99 -1 a += 1-1 84 if self.getitem(cood[0], cood[1]) in players: -1 85 a += 1 100 86 except: 101 87 pass 102 88 result.setitem(i, j, a)