master
Leo TUAILLON 2 years ago
parent bba3d1a72d
commit a7159cf104

@ -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}")

@ -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)) {

Loading…
Cancel
Save