Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

while ( currentGame - > currentGameState = = GameState::StillPlaying ) { if ( currentGame - > currentTurn ! = currentPlayer - > type ) {

while (currentGame->currentGameState == GameState::StillPlaying)
{
if (currentGame->currentTurn != currentPlayer->type)
{
printf("ERROR: Wrong player is playing. You broke it.
");
Pause();
exit(1);
}
currentGame->currentTurn =(currentPlayer->type == PlayerType::X)? PlayerType::O : PlayerType::X;
// Make a move on the game board. The result of this function will determine the current state of the board.
currentGame->currentGameState = MakeAMove(currentPlayer, currentGame);
PrintGameBoard(currentGame);
switch (currentGame->currentGameState)
{
case GameState::StillPlaying:
///////////////////////////////////////////////////////////////////////////////////
// TODO:: The game is not over yet. We need to notify the other player that it's
// their turn and then we must wait until they tell us it's our turn.
///////////////////////////////////////////////////////////////////////////////////
continue;
case GameState::Won:
///////////////////////////////////////////////////////////////////////////////////
// TODO:: We have won the game, we must wake up the other player so they can break
// out of the PlayGame function.
///////////////////////////////////////////////////////////////////////////////////
return;
case GameState::Draw:
///////////////////////////////////////////////////////////////////////////////////
// TODO:: The game ended in a tie, we must wake up the other player so they can break
// out of the PlayGame function
///////////////////////////////////////////////////////////////////////////////////
return;
}
}

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