summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2014-09-19 14:23:32 +1000
committerPeter Ward <peteraward@gmail.com>2014-09-19 14:23:32 +1000
commit96df12ddb31d086f9290fed824639c668f0455a0 (patch)
treef2b72e1cd36560e02349708f87e40178004f8d64
parent7957b69ab78adfa35f79253be792713e968452d7 (diff)
bunch of things
-rw-r--r--empty.txt12
-rw-r--r--napoleon.py25
-rw-r--r--robots/client.py5
-rw-r--r--robots/empty.txt5
-rw-r--r--robots/server.py12
5 files changed, 20 insertions, 39 deletions
diff --git a/empty.txt b/empty.txt
new file mode 100644
index 0000000..7a405b7
--- /dev/null
+++ b/empty.txt
@@ -0,0 +1,12 @@
+XXXXXXXXXXXXXXXXXXXX
+X.....+.X.+........X
+X..1.+..X.......2..X
+X....+..X....+.....X
+X...XXXXX..........X
+X..........XXXXXX..X
+X...+...........+..X
+X...XXXXXXXX..X....X
+X.....+.......X...4X
+X.............X....X
+X+.....+..3.....+..X
+XXXXXXXXXXXXXXXXXXXX
diff --git a/napoleon.py b/napoleon.py
index 2a1048c..15685eb 100644
--- a/napoleon.py
+++ b/napoleon.py
@@ -9,7 +9,6 @@ import robots
from robots.algorithms import distance_relaxer
from robots.constants import City
-from robots.utils import add_spawns
def get_close_spawns(whoami, state, threshold):
distances = []
@@ -142,24 +141,6 @@ class Napoleon:
)
if __name__ == '__main__':
-# import random
-
-# random.seed(42)
- map_ = robots.border_map(42, 22, 0)
-
- add_spawns(map_, 10, 'X')
- add_spawns(map_, 20, '+')
- add_spawns(map_, 6)
-
- game = robots.Game(map_)
-
- game.add_bot(Napoleon(), 'Napoleon')
-
- from capturer import CaptureSpawns
- game.add_bot(CaptureSpawns(), 'Alice')
- game.add_bot(CaptureSpawns(), 'Bob')
- game.add_bot(CaptureSpawns(), 'Charlie')
- game.add_bot(CaptureSpawns(), 'Doug')
-
- viewer = robots.CursesViewer(game)
- viewer.run()
+ server = robots.Server()
+ server.add_bot(Napoleon, 'Napoleon')
+ server.run()
diff --git a/robots/client.py b/robots/client.py
index 8832506..612edb1 100644
--- a/robots/client.py
+++ b/robots/client.py
@@ -1,6 +1,7 @@
import argparse
import os
import random
+import signal
from string import ascii_lowercase as lowercase
import zmq
@@ -177,6 +178,10 @@ def choose_bots():
browser = Browser(avail_walker, added_walker)
mainloop.run()
+ # This is necessary to get the sigint handler back into the correct state
+ # (despite the lies of signal.getsignal(signal.SIGINT))
+ signal.signal(signal.SIGINT, signal.default_int_handler)
+
return browser.added
class RemoteBot(object):
diff --git a/robots/empty.txt b/robots/empty.txt
deleted file mode 100644
index 1e0efe7..0000000
--- a/robots/empty.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-...........+........
-......+.............
-...1............2...
-.............+......
-........+...........
diff --git a/robots/server.py b/robots/server.py
index 1b87392..65c1136 100644
--- a/robots/server.py
+++ b/robots/server.py
@@ -1,5 +1,4 @@
from functools import wraps
-import inspect
import json
import os
import uuid
@@ -66,21 +65,10 @@ class Server(object):
>>> s.add_bot(lambda: 5, name='Alice')
>>> list(s.bots)
['Alice']
- >>> s.add_bot(lambda zebra, orange: 5, name='Bob')
- Traceback (most recent call last):
- ...
- ValueError: Bot function should have no required arguments (found: zebra, orange)
"""
if name is None:
name = fn.__name__
- argspec = inspect.getargspec(fn)
- if n_required_args(argspec) != 0:
- raise ValueError(
- 'Bot function should have no required arguments (found: %s)' %
- ', '.join(argspec.args)
- )
-
self.bots[name] = fn
def add_simple_bot(self, fn, name=None):