Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes a mi bot #42

Merged
merged 4 commits into from

2 participants

This page is out of date. Refresh to see the latest.
Showing with 11 additions and 8 deletions.
  1. +11 −8 bots/fisa.py
View
19 bots/fisa.py
@@ -50,7 +50,6 @@ def wall_between(self, position):
return True
return False
-
def messageReceived(self, msg):
msg = bunchify(msg)
@@ -81,7 +80,8 @@ def messageReceived(self, msg):
else:
# find bullets
bullets = [obj for obj in radar
- if obj.object_type == 'bullet']
+ if obj.object_type == 'bullet' and \
+ not self.wall_between(obj.position)]
incoming = []
# calculate incoming
for b in bullets:
@@ -101,8 +101,10 @@ def messageReceived(self, msg):
else:
# move N times, then rotate N times
# will hit wall?
- pointing_vector = cmath.rect(WALL_SAFE_DISTANCE, self.angle)
- pointing_vector = Vector2(pointing_vector.real, pointing_vector.imag)
+ pointing_vector = cmath.rect(WALL_SAFE_DISTANCE,
+ self.angle)
+ pointing_vector = Vector2(pointing_vector.real,
+ pointing_vector.imag)
pointing_to = predict_pos(self.pos, pointing_vector)
wall_in_front = self.wall_between(pointing_to)
@@ -155,11 +157,12 @@ def predict_pos(point, velocity, modifier=1):
return point + v
-def ccw(a,b,c):
- return (c[1]-a[1])*(b[0]-a[0]) > (b[1]-a[1])*(c[0]-a[0])
+def ccw(a, b, c):
+ return (c[1] - a[1]) * (b[0] - a[0]) > (b[1] - a[1]) * (c[0] - a[0])
+
-def intersect(a,b,c,d):
- return ccw(a,c,d) != ccw(b,c,d) and ccw(a,b,c) != ccw(a,b,d)
+def intersect(a, b, c, d):
+ return ccw(a, c, d) != ccw(b, c, d) and ccw(a, b, c) != ccw(a, b, d)
def main():
Something went wrong with that request. Please try again.