EMPTY, BLACK, WHITE, OUTER = '.', '@', 'o', '?' PIECES = (EMPTY, BLACK, WHITE, OUTER) PLAYERS = {BLACK: 'Black', WHITE: 'White'} SILENT = False # To refer to neighbor squares we can add a direction to a square. UP, DOWN, LEFT, RIGHT = -10, 10, -1, 1 UP_RIGHT, DOWN_RIGHT, DOWN_LEFT, UP_LEFT = -9, 11, 9, -11 DIRECTIONS = (UP, UP_RIGHT, RIGHT, DOWN_RIGHT, DOWN, DOWN_LEFT, LEFT, UP_LEFT) game = Strategy() board = game.initial_board() player = WHITE X_STRATEGY = game.alphabeta_search(3) O_STRATEGY = game.human_strategy(3) def play(strategy_X, strategy_O, first=WHITE): """ Plays strategy_X vs. strategy_O, beginning with first in one game. Returns X, O or TIE as a result (string) The functions make_move, next_player and terminal_test are implemented elsewhere (e.g. in core.py). The current implementation uses a 9-char string as the state, but that is not exposed at this level. """ global board global player print(game.print_board(board))
from Othello_Core import * core = OthelloCore() import random import time ############################################################# # client.py # a simple othello client # plays 2 strategies against each other and keeps score # imports strategies from "strategies.py" as ai # rest of functionality is stored in core.py # # SRINIDHI KRISHNAN ############################################################ B_STRATEGY = ai.human_strategy() W_STRATEGY = ai.minimax_strategy(6) ROUNDS = 10 SILENT = False # see core.py for constants: MAX, MIN, TIE def play(strategy_b, strategy_w, first=BLACK, silent=True): """ Plays strategy_b vs. strategy_w, beginning with first in one game. Returns score as a result (string) The functions make_move, next_player and terminal_test are implemented elsewhere (e.g. in core.py). The current implementation uses a 9-char string as the state, but that is not exposed at this level.