I'm a college student who just took a introduction to programming course for general credit. We are learning how to program with python. I am having real trouble with creating a graphical tic tac toe game. I am just a beginner and any help would be appreciated. This is what we have to do:
You will write a graphical Tic Tac Toe game. Your game should open a window, display a grid, and allow an "O" player and an "X" player to alternately click the mouse on the grid. Your program will then draw the appropriate symbol, check for victory, and then allow the other player to play. Your game will end when either player has won, or the whole board is filled up.
These are the steps you can follow:
1. Create the variables. All square variables should be set to " " and the player to "X".
2. Import graphics, make a GraphWin, and draw the four lines to make the grid.
3. Loop steps 3 through 11 using a while True: statement
4. Wait on a mouse click. Get the x and y position of the mouse.
5. Use the x and y position of the mouse to figure out which square (1 through 9) was clicked.
6. Check if the square is empty, and only do steps 311
if it is.
7. Based on player, draw an X or O in the correct square. An X should be draw with two lines, and
an O with an oval.
8. Set the appropriate square variable to "X" or "O"
9. If the player is "X", change it to "O". If the player is "O", change it to "X".
10. Check if a player has won. There are eight winning combinations (three rows, three columns,
and two diagonals). Check if any of these have happened. If so, set a won variable to the
winning player, and call break to leave the while loop.
11. Check if all squares are filled (not " "). If so, set won to nobody, and call break to leave the
12. Draw a Text line in the middle of the screen. Using the won variable, print "X Wins", "O
Wins", or "Tie".