Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a mi bot #42

Merged
merged 4 commits into from Jul 8, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions bots/fisa.py
Expand Up @@ -50,7 +50,6 @@ def wall_between(self, position):
return True
return False


def messageReceived(self, msg):
msg = bunchify(msg)

Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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():
Expand Down