COSC1302 Introduction to Computer Science and Programming Term Project: Tic Tac Toe Spring 2020 Due date: Monday, 05/11/2020 Objective: Write a Tic Tac Toe 2-player game using Python. Description:...

We use a free software product called thonny to turn in our assignments. Code must be written on there for me to turn in.


COSC1302 Introduction to Computer Science and Programming Term Project: Tic Tac Toe Spring 2020 Due date: Monday, 05/11/2020 Objective: Write a Tic Tac Toe 2-player game using Python. Description: Your Tic Tac Toe game should define at least the following functions and use specified data structures:  printBoard(): this function prints the board layout before the game starts and after each move. The initial board layout: The board layout after each move, for example:  board should be defined as a dictionary, for example, o the initial board: {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9} o the board after each move: for example: {1:'o', 2:2, 3:3, 4:'o', 5:5, 6:6, 7:'x', 8:'o', 9:9}  flipCoin(): before the game starts, program will flip a coin to decide who makes the first move. This function should randomly generates 0 or 1 and returns it.  move(position): put marks on the board, position is between 1 and 9.  isValid(position): should be called after each move. Returns True if a move is valid, otherwise, returns False. o A move is valid if (1) the position number is between 1 and 9 AND (2) the position is available, i.e., has not been marked yet. o If a move is not valid, it can either stop the game, or keep asking for a move until the player input a valid position (Extra 5 points).  checkStatus(): check if game is over. Returns 1 if the player1 wins, returns 2 if player2 wins, and returns 0 if tied. Sample run #1: *************** * TIC TAC TOE * *************** Player1's name: Jason Player2's name: Annie Jason, choose Head or Tail Enter 0 for heads, 1 for tails: 0 Head! Jason makes the first move *** GAME STARTS *** Jason: 'o' Annie: 'x' 1 | 2 | 3 ---|---|--- 4 | 5 | 6 ---|---|--- 7 | 8 | 9 Jason next move: o = 5 1 | 2 | 3 ---|---|--- 4 | o | 6 ---|---|--- 7 | 8 | 9 Annie next move: x = 9 1 | 2 | 3 ---|---|--- 4 | o | 6 ---|---|--- 7 | 8 | x Jason next move: o = 1 o | 2 | 3 ---|---|--- 4 | o | 6 ---|---|--- 7 | 8 | x Annie next move: x = 6 o | 2 | 3 ---|---|--- 4 | o | x ---|---|--- 7 | 8 | x Jason next move: o = 3 o | 2 | o ---|---|--- 4 | o | x ---|---|--- 7 | 8 | x Annie next move: x = 2 o | x | o ---|---|--- 4 | o | x ---|---|--- 7 | 8 | x Jason next move: o = 7 o | x | o ---|---|--- 4 | o | x ---|---|--- o | 8 | x Jason wins! Game over! Sample run #2: *************** * TIC TAC TOE * *************** Player1's name: Jason Player2's name: Annie Jason, choose Head or Tail Enter 0 for heads, 1 for tails: 0 Tail! Annie makes the first move *** GAME STARTS *** Jason: 'o' Annie: 'x' 1 | 2 | 3 ---|---|--- 4 | 5 | 6 ---|---|--- 7 | 8 | 9 Annie next move: x = 5 1 | 2 | 3 ---|---|--- 4 | x | 6 ---|---|--- 7 | 8 | 9 Jason next move: o = 1 o | 2 | 3 ---|---|--- 4 | x | 6 ---|---|--- 7 | 8 | 9 Annie next move: x = 9 o | 2 | 3 ---|---|--- 4 | x | 6 ---|---|--- 7 | 8 | x Jason next move: o = 3 o | 2 | o ---|---|--- 4 | x | 6 ---|---|--- 7 | 8 | x Annie next move: x = 2 o | x | o ---|---|--- 4 | x | 6 ---|---|--- 7 | 8 | x Jason next move: o = 8 o | x | o ---|---|--- 4 | x | 6 ---|---|--- 7 | o | x Annie next move: x = 6 o | x | o ---|---|--- 4 | x | x ---|---|--- 7 | o | x Jason next move: o = 4 o | x | o ---|---|--- o | x | x ---|---|--- 7 | o | x Annie next move: x = 7 o | x | o ---|---|--- o | x | x ---|---|--- x | o | x Tie Game over!
Apr 30, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here