Python Forum

Full Version: Tic Tac Toe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, I’m creating a 2 player tic tac toe game and I’m unsure on how I would start programming it. So I was wondering if someone could help me or give me a suggestion. I going to make it simple by not asking what player1 name and player2 name is. so when you run the program, the first number entered by the user indicates the option the user is selecting. Inputs the current status of a standard tic tac toe board and outputs the board. If a place on the board is blank, a ‘b’ will be entered by the user.

Locations :
TL TM TR
ML MM MR
BL BM BR

Note: TL means ‘Top Left’, TM means ‘Top Middle’; TR means ‘Top Right’, etc.

This is how the input and output should look like
https://codecademy-discourse.s3.dualstac...0dbfd9.png
What is your question?
How Would I start programming this game?
I would start with a list of lists for the board, with the cells either 'X', 'O', or ' '. Then a couple of join statements can print the board, and indexes can be entered to identify the cells. You can also use the strip mentod to tell if a cell is empty. There are only eight possible wins, so just put the indexes for those in a list, and then you can use a for loop to check for wins.
Can you show me a example on how I would start this
We're not going to write it for you. You need to write some code, and come back to use when you run into problems. Be sure to use BBCode tags (link below) when posting your code, and to clearly explain the problem you are having.