diff options
author | Peter Ward <peteraward@gmail.com> | 2011-05-27 17:07:10 +1000 |
---|---|---|
committer | Peter Ward <peteraward@gmail.com> | 2011-05-27 17:07:10 +1000 |
commit | 0549a8a244a89778e2c39d14b98adfcc8a0b2526 (patch) | |
tree | b967448791f174442b924f904744a21648dfb30e | |
parent | a7500846e6d54f5b7c0f9e26cca63656dbdf3a29 (diff) |
Remove process bot as well.
-rw-r--r-- | processbot.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/processbot.py b/processbot.py deleted file mode 100644 index 15e7de0..0000000 --- a/processbot.py +++ /dev/null @@ -1,53 +0,0 @@ -import sys -import subprocess - -class BotWrapper(object): - def __init__(self, process): - self.process = process - self.__name__ = process - - def __call__(self, board, (x, y)): - height = len(board) - width = len(board[0]) - - letter = board[y][x].lower() - - proc = subprocess.Popen( - [self.process], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - ) - - board = '\n'.join([''.join(row) for row in board]) - - print>>proc.stdin, width, height, letter - print>>proc.stdin, board - proc.stdin.close() - proc.wait() - - assert proc.returncode == 0, 'Snake died.' - output = proc.stdout.read() - return output.strip() - -def process_input(fp=sys.stdin): - width, height, letter = fp.readline().split() - - width = int(width) - height = int(height) - letter = letter.upper() - - position = None - - board = [] - for i in xrange(height): - row = fp.readline()[:-1] - assert len(row) == width - - pos = row.find(letter) - if pos >= 0: - position = (pos, i) - - board.append(list(row)) - - return board, position - |