summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpitfireX <timm.weber@me.com>2015-08-11 05:59:04 +0200
committerSpitfireX <timm.weber@me.com>2015-08-11 05:59:04 +0200
commit804cf4d8145a53722739b4cad8dbbacdf0bf166c (patch)
tree844c61f13ae49a6eae0fc0d3114539567988f64a
parent5b5db451134901077a57c1c5bf73fe3a70ed1fee (diff)
Fixed locking onto moving cells as food
I totally forgot to account for moving food, derp.
-rw-r--r--main.py10
1 files 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")