Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #42 from fisadev/master

Fixes a mi bot
  • Loading branch information...
commit 6bcb3330c20a89adecea64d4a499eaf12b2b8af2 2 parents be94fa3 + 205254e
@elachuni elachuni authored
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():
Please sign in to comment.
Something went wrong with that request. Please try again.