Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help for this tictactoe gameboard problem (in python) tictactoe-Gameboard Instructions: Your mission is to write a program that mimics Tic Tac Toe. It should be

Help for this tictactoe gameboard problem (in python)

tictactoe-Gameboard Instructions: Your mission is to write a program that mimics Tic Tac Toe. It should be a one-player game against the computer. Rules for TIC-TAC-TOE: The game is played on a grid that's 3 squares by 3 squares. You are X, your friend (or the computer in this case) is O. ... The first player to get 3 of her marks in a row (up, down, across, or diagonally) is the winner. When all 9 squares are full, the game is over. You must be able to: take in moves, display the board as it progresses, and check for (announce) a winner. Example boards: ['', '', ''] ['', '', ''] ['', '', ''] ['X', '', 'O'] ['', 'X', 'O'] ['O', '', 'X']

here's what I have so far:

#create an empty game board board= [['', '', ''], ['', '', ''], ['', '', '']] board_options= [['0,0', '0,1', '0,2'], ['1,0', '1,1', '1,2'], ['2,0', '2,1', '2,2']] def main(): #print player is 'X' print('The player is X') ##explain how the player can move #display plane w/#s for row in board_options: print(row) print('enter a coordinate (x,y) to place your "X" piece: ') player_X= int(input('enter an X value 0-2: ')) if player_X < 0 or player_X > 2: print('invalid') player_X= int(input('enter a coordinate (x,y) to place your "X" piece: ')) player_y= int(input('enter a Y value 0-2: ')) if player_y < 0 or player_y > 2: print('invalid') player_y= int(input('enter a coordinate (x,y) to place your "X" piece: ')) fillboard(player_X, player_y) def fillboard(player_X, player_y): board[player_X][player_y]= 'X' for row in board: print(row) main() 

I'm having trouble figuring out how to make the computer initiate a randomized move, how to reiterate the player choice, and how to check for a winner.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

d. What language(s) did they speak?

Answered: 1 week ago