Aug-06-2017, 08:48 PM
I see. If there is no win, gameRun never gets defined in checkX. I should have seen that coming. To fix that, put
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'.
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
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures