diff --git a/TicTacToe.py b/TicTacToe.py index 8b2827d..9545a34 100644 --- a/TicTacToe.py +++ b/TicTacToe.py @@ -155,7 +155,6 @@ class AI: else: #minimax algo choice print("AI is thinking...") - time.sleep(1) eval, move = self.minimax(main_matrix, False) print(f"AI has chosen the pos {move} with an eval of {eval}") diff --git a/__pycache__/constants.cpython-310.pyc b/__pycache__/constants.cpython-310.pyc deleted file mode 100644 index 598e2be..0000000 Binary files a/__pycache__/constants.cpython-310.pyc and /dev/null differ diff --git a/__pycache__/constants.cpython-311.pyc b/__pycache__/constants.cpython-311.pyc deleted file mode 100644 index 8bfdf01..0000000 Binary files a/__pycache__/constants.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/constants.cpython-39.pyc b/__pycache__/constants.cpython-39.pyc deleted file mode 100644 index b401ac6..0000000 Binary files a/__pycache__/constants.cpython-39.pyc and /dev/null differ diff --git a/script.js b/script.js index 3475323..686a3bd 100644 --- a/script.js +++ b/script.js @@ -63,8 +63,10 @@ class AI { minimax(matrix, depth, maximizingPlayer) { const winner = this.check_winner(matrix); - if (winner !== 0) { - return winner === this.player ? 10 - depth : depth - 10; + if (winner === this.player) { + return 1; + } else if (winner === 3 - this.player) { + return -1; } if (matrix.is_full()) { @@ -96,6 +98,7 @@ class AI { return bestScore; } + check_winner(matrix) { for (let player = 1; player <= 2; player++) { if (matrix.check_win(player)) {