From a7500846e6d54f5b7c0f9e26cca63656dbdf3a29 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Fri, 27 May 2011 17:06:27 +1000 Subject: Preparation for new process bot. --- bots.py | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 bots.py (limited to 'bots.py') 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 - -- cgit v1.2.3