Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents fe3cfda + 188fa45 commit 5b2576fc496d516f880b5ede08940c023662c708 @fisadev fisadev committed Jul 8, 2012
Showing with 41 additions and 6 deletions.
  1. +1 −1 bots/maptools.py
  2. +23 −0 bots/nico.py
  3. +1 −1 bots/seeker.py
  4. +1 −4 bots/sulu.py
  5. +15 −0 fabfile.py
View
@@ -271,7 +271,7 @@ def waypoint(self, start, goal):
return self.cell_to_world(*way)
def set_goal(self, goal):
- self.goal = self.world_to_cell(*goal)
+ self.goal = self.player_world_to_cell(*goal)
Q = set()
self.goalpath = D = {}
View
@@ -0,0 +1,23 @@
+from twisted.internet.protocol import ClientFactory
+from twisted.internet import reactor
+from random import random
+
+import spacecraft
+
+
+class NicoClient(spacecraft.server.ClientBase):
+ name = 'nico bot'
+ def messageReceived(self, message):
+ self.command("throttle", value=1)
+ self.command("fire")
+ if random() < 0.2:
+ self.command("turn", value=1)
+
+def main():
+ factory = ClientFactory()
+ factory.protocol = NicoClient
+ reactor.connectTCP("localhost", 11106, factory)
+
+if __name__ == "__main__":
+ reactor.callWhenRunning(main)
+ reactor.run()
View
@@ -91,7 +91,7 @@ def messageReceived(self, message):
self.way = random.choice(self.waypoints)
self.gridmap.set_goal(self.way)
- if pp is not None:
+ if pp is not None and enemies == 0:
# a powerup!!!
print "poweeeeeeeeeeeeer"
if self.gridmap.visible(self.pos, pp):
View
@@ -1,6 +1,6 @@
from twisted.internet.protocol import ClientFactory
from twisted.internet import reactor
-from random import shuffle, choice
+from random import choice
from spacecraft.client_helpers import relative_angle
from spacecraft.euclid import LineSegment2, Point2, Matrix3
from math import sqrt, atan2, pi
@@ -167,9 +167,6 @@ def parse_sensor(self, message):
options = [o for o in options if o.visits == options[0].visits]
#~ print "Options:", options
self.going = max(options, key=lambda t:t.distance_to(x, y))
- # Random exploration
- #~ shuffle(options)
- #~ self.going = min(options, key=lambda t:t.visits)
speed = speedx**2 + speedy**2
speedangle = atan2(speedy, speedx)
targetangle = atan2(self.going.y - y, self.going.x - x)
View
@@ -60,6 +60,21 @@ def versus(bot1, bot2, *server_args):
for proc in procs:
proc.terminate()
+def cross(*bots):
+ """Start a server and two clients, and a monitor to watch them"""
+ check_bootstrap()
+ procs = []
+ procs.append(subprocess.Popen(
+ ['./virtualenv/bin/twistd', '-n', 'spacecraft', '--map',
+ 'maps/cross.svg', '--xsize', '300', '--ysize', '300']))
+ sleep(2)
+ for bot in bots:
+ procs.append(subprocess.Popen(
+ ['./virtualenv/bin/python', bot], env={'PYTHONPATH': '.'}))
+ local('PYTHONPATH=. ./virtualenv/bin/python spacecraft/monitor.py --size 600x600')
+ for proc in procs:
+ proc.terminate()
+
# -----------------------------------------------------------------
# Tasks from here down aren't intended to be used directly

0 comments on commit 5b2576f

Please sign in to comment.