Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Won't let me end a loop
#6
I see. If there is no win, gameRun never gets defined in checkX. I should have seen that coming. To fix that, put gameRun = True at the beginning of checkX.

You're going to have another problem. gameRun is being changed in the middle of the loop. So after player one wins, it asks player two to make a move. Also, it never checks if player two wins. I think you should generalize your code, so that each time through the loop, one player moves. Have a playerNumber variable that is 'one' or 'two', and a playerSymbol variable that is 'X' or 'O'. Then after one player moves, switch those variables and loop back for the next player.

Then generalize your check code, so it can check for X or O, depending on what you ask it to do. So have checkX accept a symbol parameter, and then check the grid locations against symbol instead of 'X'.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Won't let me end a loop - by mzmingle - Aug-06-2017, 07:07 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 07:55 PM
RE: Won't let me end a loop - by mzmingle - Aug-06-2017, 08:03 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 08:05 PM
RE: Won't let me end a loop - by mzmingle - Aug-06-2017, 08:28 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 08:48 PM
RE: Won't let me end a loop - by mzmingle - Aug-06-2017, 08:56 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 09:58 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020