diff --git a/.idea/Python_Project.iml b/.idea/Python_Project.iml new file mode 100644 index 0000000..31f7130 --- /dev/null +++ b/.idea/Python_Project.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6abb96f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9194a2c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tictactoe/__pycache__/tictactoe.cpython-313.pyc b/tictactoe/__pycache__/tictactoe.cpython-313.pyc new file mode 100644 index 0000000..a57b3eb Binary files /dev/null and b/tictactoe/__pycache__/tictactoe.cpython-313.pyc differ diff --git a/tictactoe/tictactoe.py b/tictactoe/tictactoe.py index ac79dfb..24df58c 100644 --- a/tictactoe/tictactoe.py +++ b/tictactoe/tictactoe.py @@ -16,7 +16,7 @@ def player(board): o_count = sum(row.count(O) for row in board) return O if x_count > o_count else X - +# Returns the list of empty positions on the board def actions(board): """Returns a list of all possible actions (i, j) available on the board.""" return [(i, j) for i in range(3) for j in range(3) if board[i][j] is EMPTY] @@ -116,10 +116,12 @@ def min_value(board): if __name__ == "__main__": + print("Welcome to Tic-Tac-Toe! This game will play itself using AI.") board = initial_state() while not terminal(board): move = minimax(board) board = result(board, move) print(f"Player {player(board)} made move: {move}") for row in board: - print(row) + print(" | ".join([cell if cell else " " for cell in row])) + print()