From 1b71192eca047f8d13d6570bb623627389e5acc3 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 31 Aug 2015 18:10:17 +0200 Subject: 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. --- subscriber.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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] = [] -- cgit v1.2.3