| 0 | 1 | 2 || 3 | 4 | 5 || 6 | 7 | 8 |X's turn. Input move (0-8): 4X makes a move to square 4| | | || | X | || | | |O makes a move to square 0| O | | || | X | || | | |X's turn. Input move (0-8): 8X makes a move to square 8| O | | || | X | || | | X |O makes a move to square 2| O | | O || | X | || | | X |X's turn. Input move (0-8): 0Invalid square. Try again.X's turn. Input move (0-8): 6X makes a move to square 6| O | | O || | X | || X | | X |O makes a move to square 1| O | O | O || | X | || X | | X |O wins!
You can easily modify game.py to change the player configuration:
game.py
# Human vs Humanx_player = HumanPlayer('X')o_player = HumanPlayer('O')# Random AI vs Genius AIx_player = RandomComputerPlayer('X')o_player = GeniusComputerPlayer('O')# Human vs Random AIx_player = HumanPlayer('X')o_player = RandomComputerPlayer('O')ttt = TicTacToe()play(ttt, x_player, o_player)
The genius AI is unbeatable - you can only achieve a tie at best when playing optimally!