From f29f1280a26105e1956fcb79b38f4e319060286c Mon Sep 17 00:00:00 2001 From: letuaillon Date: Tue, 25 Apr 2023 09:39:33 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20de=20s=20pour=20que=20l'IA=20commence?= =?UTF-8?q?=20=C3=A0=20jouer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TicTacToe.py | 12 +++++++++++- __pycache__/constants.cpython-311.pyc | Bin 0 -> 539 bytes 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 __pycache__/constants.cpython-311.pyc diff --git a/TicTacToe.py b/TicTacToe.py index c733b69..d1928f4 100644 --- a/TicTacToe.py +++ b/TicTacToe.py @@ -226,6 +226,16 @@ class Game: self.make_move(row, column) self.ai_starts = False + # ... + def start_ai_turn(self): + if self.gamemode == 'ai' and self.player == self.ai.player and self.ai_starts: + row, column = self.ai.evaluate(self.matrix) + self.make_move(row, column) + self.ai_starts = False + # ... + + + def main(): # Object of Game class @@ -251,7 +261,7 @@ def main(): # s-start if event.key == pygame.K_s: game.ai_starts = not game.ai_starts - game.ai_first_move() + game.start_ai_turn() #r-restart if event.key == pygame.K_r: diff --git a/__pycache__/constants.cpython-311.pyc b/__pycache__/constants.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8bfdf01edc33e9fa1a67033e528a0e87af81a940 GIT binary patch literal 539 zcmXw$ze~eF6vr=3n>K0Aw&3D#9UQs{I*JH2jWrk=O;SpaK&ZV8f?7$cpi}+?opg6l z{|;wCCqt%!Q@27FanW}s-tj*7{l53^2izmZ5`yt`*`Qqxp-*Q1MI9Ov3v-QJ4@U2Qh@>{x7=THQ5` zwv|f7&_OCSOLZ-csIjDLP1Q{{VMQ|)U3JY`U29pfoZ6&VR7}IN($4ZuP1$dlMypwO z;Y7ns&q*{s&}$vl+(=8QT~F*Yn!tO}_iAs`X$77iI453zaN*d;J-gep`<~P5p9O>N z*&tXuzxpn0o%ZR)iMQ=9!7lhC6gYq}&vD#XK%yMxB7iWIaVSO%L%DL(d6ySK;Zi6; qQ)Tx4@OCQ1QK=Hj;9)6_3ut=f4V5E26G~Be9;)TJ5VPqozy-hA{f!g= literal 0 HcmV?d00001