Python Forum

Full Version: Horror on TicTacToe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there !
I'm a frist year IT student.
I have an issue with my IA on my TicTacToe script.
For now, she's working but she's playing twice on his fturns and i dont't know why.
I'v verified all the conditions and for me the "breaks" are good and the alternate turns are OK . Can you help me find what the point with his behaviour ?

Thank you for your help !
(Nov-01-2024, 08:42 PM)revan Wrote: [ -> ]Hi there !
I'm a frist year IT student.
I have an issue with my IA on my TicTacToe script.
For now, she's working but she's playing twice on his fturns and i dont't know why.
I'v verified all the conditions and for me the "breaks" are good and the alternate turns are OK . Can you help me find what the point with his behaviour ?

Thank you for your help !

Hi, you have the testia.placement() function which makes it's play. But then call the testia.second_placement() which appears to make the second placement. See lines 98-103 in your FINALV2.py code.

            testia.placement(game_board)
            winner, symbol = winner_or_not(game_board)
            if winner:
                interface_tictactoe(game_board)
                print("Computer wins...")
                break
            
      #      testia.second_placement(game_board)
      #      winner, symbol = winner_or_not(game_board)
      #      if winner:
      #          interface_tictactoe(game_board)
      #          print("Computer wins...")
      #          break

            turn_played = True  # switch back to the player
Commenting the second one seems to fix the double play.