Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C PROGRAMMING INCLUDE MAIN FOR TESTING WILL GIVE RATING TicTacToe Basics Next, you will write a function that takes a board in unsigned short (us)

C PROGRAMMING

INCLUDE MAIN FOR TESTING

WILL GIVE RATING

image text in transcribed

TicTacToe Basics Next, you will write a function that takes a board in unsigned short (us) format and determines who the winner of the board is. .e. if there are three Xs in a row, column or diagonal, then X has won, and your function should return the value '2' (not 2). Similarly, for O, it should return the value '1' (not 1). Note that it is possible to create boards where both X and O win at the same time, e.g. 222000111(3but these boards will not occur in a real game, so you are not required to worry about this case (we will not test your function which boards that cannot occur). Hint, feel free to use the b3fromus function that you created above to convert the unsigned short into a representation where you can more easily determine a winner. char winner unsigned short us); Next, you will write a function that determines what the next board looks like if a player places their symbol in a given position. Position O, is the top left, 1 is the top middle, 2 is top right, 3 is middle left,. 8 is bottom right. f there is already a piece in the given position your function should return the value 0. Note that this function also uses the unsigned short representation, but you can convert to and from b3 inside your function to make it easier. unsigned short next unsigned short us, For example, if us is 100020000(3), and pos is 6, then the return value should be 1000202003) But if pos is 0, then the return value should be 000000000(3). You don't need to worry about the case where a player has already won the game. Now, you will write a function that will return an integer indicating what move of the game it is. A move consists of one action by one player. The first move is 0, the next move is 1, etc., so you can just count the number of pieces on the board. char get move( char b3 [101 Finally, you will write a function that will return a character indicating whose turn is it. '2' means X's turn, '1 means O's turn. char get_turn(char b3

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

Students also viewed these Databases questions