summaryrefslogtreecommitdiff
path: root/bots.py
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2011-05-27 17:06:27 +1000
committerPeter Ward <peteraward@gmail.com>2011-05-27 17:06:27 +1000
commita7500846e6d54f5b7c0f9e26cca63656dbdf3a29 (patch)
tree934ea04ea68f97e8881b45489a28d619330d2023 /bots.py
parente0962ffe58cd43534ebc98ee7e83f70b992855a8 (diff)
Preparation for new process bot.
Diffstat (limited to 'bots.py')
-rw-r--r--bots.py52
1 files changed, 0 insertions, 52 deletions
diff --git a/bots.py b/bots.py
deleted file mode 100644
index f3e7cee..0000000
--- a/bots.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import random
-
-from common import *
-
-def right_bot(board, (x, y)):
- return 'R'
-
-def random_bot(board, (x, y)):
- return random.choice('UDLR')
-
-def random_bounds_bot(board, (x, y)):
- height = len(board)
- width = len(board[0])
- moves = []
- if x > 0:
- moves.append('L')
- if x < width - 1:
- moves.append('R')
- if y > 0:
- moves.append('U')
- if y < height - 1:
- moves.append('D')
-
- move = 'U'
- while moves and move not in moves:
- move = random_bot(board, (x, y))
- return move
-
-def random_square_bot(board, (x, y)):
- def in_bounds(x, y, w, h):
- return x >= 0 and y >= 0 and x < w and y < h
-
- h = len(board)
- w = len(board[0])
-
- todo = directions.keys()
-
- move = random_bot(board, (x, y))
- dx, dy = directions[move]
- nx = x + dx
- ny = y + dy
-
- while todo and in_bounds(nx, ny, w, h) and \
- board[ny][nx] not in (Squares.EMPTY, Squares.APPLE):
- if move in todo:
- todo.remove(move)
- move = random_bot(board, (x, y))
- dx, dy = directions[move]
- nx = x + dx
- ny = y + dy
- return move
-