@@ -0,0 +1,2361 @@
+%22%22%22%0AMini-max Tic-Tac-Toe Player%0A%0AAuthor: Weikang Sun%0ADate: 10/29/15%0A%0ACodeSkultpor source:%0Ahttp://www.codeskulptor.org/#user40_nOKLY8YOrB_15.py%0A%22%22%22%0A%0Aimport poc_ttt_gui%0Aimport poc_ttt_provided as provided%0A%0A# Set timeout, as mini-max can take a long time%0Aimport codeskulptor%0Acodeskulptor.set_timeout(60)%0A%0A# SCORING VALUES - DO NOT MODIFY%0ASCORES = %7Bprovided.PLAYERX: 1,%0A          provided.DRAW: 0,%0A          provided.PLAYERO: -1%7D%0A%0Adef mm_move(board, player):%0A    %22%22%22%0A    Make a move on the board.%0A    %0A    Returns a tuple with two elements.  The first element is the score%0A    of the given board and the second element is the desired move as a%0A    tuple, (row, col).%0A    %22%22%22%0A    %0A    # check status of game%0A    status = board.check_win()%0A    %0A    # recursive case, when game is not yet finished%0A    if status is None:%0A        avail_moves = board.get_empty_squares()%0A        %0A        # set a score impossibly low with invalid move%0A        max_score = -2%0A        best_move = (-1, -1)%0A        %0A        for move in avail_moves:%0A            # remember to iterate on a clone of the board%0A            game = board.clone()%0A            game.move(move%5B0%5D, move%5B1%5D, player)%0A            # get the best score from the new board based on player%0A            mm_result, dummy_var = mm_move(game, provided.switch_player(player))%0A            mm_result *= SCORES%5Bplayer%5D%0A            %0A            # short circuit in event of winning move%0A            if mm_result == 1:%0A                return SCORES%5Bplayer%5D, move%0A%0A            elif mm_result %3E max_score:%0A                max_score = mm_result%0A                best_move = move%0A        # return the best move available    %0A        return SCORES%5Bplayer%5D*max_score, best_move  %0A    %0A    # base cases, when game is already finished%0A    else:%0A        return SCORES%5Bstatus%5D, (-1, -1)%0A    %0A%0Adef move_wrapper(board, player, trials):%0A    %22%22%22%0A    Wrapper to allow the use of the same infrastructure that was used%0A    for Monte Carlo Tic-Tac-Toe.%0A    %22%22%22%0A    move = mm_move(board, player)%0A    assert move%5B1%5D != (-1, -1), %22returned illegal move (-1, -1)%22%0A    return move%5B1%5D%0A%0A# Test game with the console or the GUI.%0A# Uncomment whichever you prefer.%0A# Both should be commented out when you submit for%0A# testing to save time.%0A%0A# provided.play_game(move_wrapper, 1, False)        %0A# poc_ttt_gui.run_gui(3, provided.PLAYERO, move_wrapper, 1, False)%0A%0A%0A%0A

Create 8-tictactoe-minimax.py