Question
1. This is a two player (X's and O'x) board game. 2. The game board is a 3 X 3 grid, where each location can
1. This is a two player (X's and O'x) board game.
2. The game board is a 3 X 3 grid, where each location can hold either and 'X' an 'O' or a space (empty) Note: we will linearize the grid and refer to the locations 1-9, for conveyance.
3. The players take turns placing their mark into one of the empty locations in the grid.
4. The game won when a player has their mark in all three locations of any row, column, or diagonal.
5.- The game can also reach a stalemate: neither player has won (by above criteria) however all there are no more empty locations in the grid.
outline:
1. Create a MATLAB Script.m file
A) Establish variable(s) to represent the nine board locations
B)Create the game loop
i. Display the current state of the board - using separate displayboad function
ii) get a "valid" move location - note this can only be an empty location
iii) Modify the board variable(s)
iv) check for a win and report if so - game must end
v) Check for a stalemate - game must end
2. Create a MATLAB funciton.m file
A) Establish its name (displayboard), input(s), and output (there really is not any)
B) Write the necessary MATLAB commands to display the Tic-Tac-Toe board, using the give inputs.
3. Make sure to test your script and function when they are done.
NOTE: Keep track of the total number of moves, for an easy stalemate detection. Your location choice user-validation loop must also not accept any location that is not currently empty.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started