Question: Exercise 1 : Write a function that creates an n by n matrix ( of list of lists ) which will represent the state of

Exercise 1: Write a function that creates an n by n matrix (of list of lists) which will represent the state of a Tie Tac Toe game. Let 0,1, and 2 represent empty, "X", and "O", respectively.
*Exercise 2:" Write a function that takes 2 integers 'n' and 'm' as input and draws a 'n' by 'm' game board. For example the following is a 33 board:
Exercise 3: Modify exercise 2, so that it takes a matrix of the form from exercise 1 and draws a tic-tac-tie board with "X"s and "O"s.
Exercise 4: Write a function that takes a n by n matrix representing a tic-tac-toe game, and returns -1,0,1, or 2 indicating the game is incomplete, the game is a draw, player 1 has won, or player 2 has one, respectively.
Here are some example inputs you can use to test your code:
winner_is_2=[[2,2,0],
2,1,0,
[2,1,1]
winner_is_1=[[1,2,0],
2,1,0,
[2,1,1]
winner_is_also_1=,
2,1,0,
[2,1,1]
no_winner =[[1,2,0],
2,1,0,
[2,1,2]]
also_no_winner =[[1,2,0],
2,1,0,
[2,1,0]
Exercise 5: Write a function that takes a game board, player number, and (x,y) coordinates and places "X" or "O" in the correct location of the game board. Make sure that you only allow filling previously empty locations. Return True or False to indicate successful placement of "X" or "O".
Exercise 6: Modify Exercise 4 to show column and row labels so that players can specify location using "A2" or "C1"
Exercise 7: Write a function that takes a board, player number, and location specified as in exercise 6 and then calls exercise 5 to correctly modify the board.
# Write you solution here
[]:
]
[2,1,0]
[[2,1,0]
Exercise 5: Write a function that takes a game board, player number, and (x,y) coordinates and places "X" or "O" in the correct location of the game board. Make sure that you only allow filling previously empty locations. Return True or False to indicate successful placement of "X" or "O".
Exercise 6: Modify Exercise 4 to show column and row labels so that players can specify location using "A2" or "C1"
Exercise 7: Write a function that takes a board, player number, and location specified as in exercise 6 and then calls exercise 5 to correctly modify the board.
# Write you solution here
[]:
[]:
# Test your solution here
Exercise 8: Write a function is called with a board and player number, takes input from the player using python's input, and modifies the board using your function from exercise 7. Note that you should keep asking for input until you have gotten a valid input that results in a valid move.
# Write you solution here
[]:
]:
# Test your solution here
Exercise 9: Use all of the previous exercises to implement a full tic-tac-toe game, where an appropriate board is drawn, 2 players are repeatedly asked for a location coordinates of where they wish to place a mark, and the game status is checked until a player wins or a draw occurs.
# Write you solution here
[]:
# Test your solution here
[]:
Exercise 10: Test that your game works for 55 Tic Tac Toe.
# Test your solution here
[]:
Exercise 11: (Advanced / Challenge) Develop a version of the game where one player is the computer. Note that you don't need to do an extensive seach for the best move. You can have the computer simply protect against loosing and otherwise try to win with straight or diagonal patterns.
# Write you solution here
[]:
 Exercise 1: Write a function that creates an n by n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!