summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-08-11 02:56:34 +0200
committerFlorian Jung <flo@windfisch.org>2015-08-11 02:56:34 +0200
commit81cf68d67206c2aff32069821f5454d06a157ced (patch)
treea0174e52159eb76ddf7833030e2867782a46c30f
parent2d1c5a31976425608e0fe22a1a6d07cbc24777ba (diff)
avoid walls when fleeing
-rw-r--r--main.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.py b/main.py
index b9294fa..477e122 100644
--- a/main.py
+++ b/main.py
@@ -52,12 +52,20 @@ while True:
relpos = ((cell.pos[0]-c.player.center[0]),(cell.pos[1]-c.player.center[1]))
dist = math.sqrt(relpos[0]**2+relpos[1]**2)
- if (not cell.is_virus and dist < 100+cell.size and cell.mass > 1.1 * my_smallest) or (cell.is_virus and dist < cell.size and cell.mass < my_largest):
+ if (not cell.is_virus and dist < 300+2*cell.size and cell.mass > 1.1 * my_smallest) or (cell.is_virus and dist < cell.size and cell.mass < my_largest):
angle = math.atan2(relpos[1],relpos[0])
corridor_width = 2 * math.asin(cell.size / dist)
forbidden_intervals += canonicalize_angle_interval((angle-corridor_width, angle+corridor_width))
runaway=True
+ if c.player.center[0] < c.world.top_left[1]+c.player.total_size:
+ forbidden_intervals += [(0.5*pi, 1.5*pi)]
+ if c.player.center[0] > c.world.bottom_right[1]-c.player.total_size:
+ forbidden_intervals += [(0,0.5*pi), (1.5*pi, 2*pi)]
+ if c.player.center[1] < c.world.top_left[0]+c.player.total_size:
+ forbidden_intervals += [(0, pi)]
+ if c.player.center[1] > c.world.bottom_right[0]-c.player.total_size:
+ forbidden_intervals += [(pi, 2*pi)]
if (runaway):
forbidden_intervals = merge_intervals(forbidden_intervals)