summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-08-31 18:10:17 +0200
committerFlorian Jung <flo@windfisch.org>2015-08-31 18:14:55 +0200
commit1b71192eca047f8d13d6570bb623627389e5acc3 (patch)
treeccfde3e594f5b2bb17276223a5f29a8f64e8f88c
parent50921e339daf8f2c4cae8ab792e97b8a35a90dbe (diff)
fixed weird problem, wtf
before this change, the bot was always heading to (0,0), instead of heading towards the next available food. This seems to be related to world.cells being a defaultdict(Cell) (and not an ordinary dict). Also, changing the dict index `eater_id` to something nonexistent like `1`, the bug vanished as well.
-rw-r--r--subscriber.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/subscriber.py b/subscriber.py
index 4327e04..ecec729 100644
--- a/subscriber.py
+++ b/subscriber.py
@@ -99,8 +99,9 @@ class EnhancingSubscriber(DummySubscriber):
del self.victims[eater]
def on_cell_eaten(self, eater_id, eaten_id):
- if self.c.world.cells[eater_id].is_virus:
+ if eater_id in self.c.world.cells and self.c.world.cells[eater_id].is_virus:
print("virus ate something!")
+
if eater_id not in self.victims:
self.victims[eater_id] = []