From 804cf4d8145a53722739b4cad8dbbacdf0bf166c Mon Sep 17 00:00:00 2001 From: SpitfireX Date: Tue, 11 Aug 2015 05:59:04 +0200 Subject: Fixed locking onto moving cells as food I totally forgot to account for moving food, derp. --- main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 15e438b..5026269 100644 --- a/main.py +++ b/main.py @@ -90,10 +90,12 @@ while True: color = (255,0,0) print ("Running away: " + str((runaway_x-c.player.center[0], runaway_y-c.player.center[1]))) else: - if target_cell not in c.world.cells.values(): - target_cell = None - has_target = False - print("target_cell does not exist any more") + if target_cell != None: + target = tuple(target_cell.pos) + if target_cell not in c.world.cells.values(): + target_cell = None + has_target = False + print("target_cell does not exist any more") elif target == tuple(c.player.center): has_target = False print("Reached random destination") -- cgit v1.2.3