Some Logic tidy

This commit is contained in:
2023-03-01 21:34:46 -08:00
parent f1a3ee8579
commit 5675e99f0f
3 changed files with 29 additions and 13 deletions

View File

@ -44,6 +44,17 @@ enum TicTacToeTileState Dawn::ticTacToeDetermineWinner(
return TIC_TAC_TOE_EMPTY;
}
bool_t Dawn::ticTacToeIsGameOver(
const std::map<uint8_t, enum TicTacToeTileState> board
) {
auto it = board.begin();
while(it != board.end()) {
if(it->second == TIC_TAC_TOE_EMPTY) return false;
++it;
}
return true;
}
int32_t Dawn::ticTacToeGetBoardScore(
std::map<uint8_t, enum TicTacToeTileState> board,
enum TicTacToeTileState player

View File

@ -25,6 +25,17 @@ namespace Dawn {
std::vector<uint8_t> *winningCombo
);
/**
* Returns true if the tic tac toe game is over. Will also consider ties as a
* game over state.
*
* @param board Board to check if game has ended.
* @return True if game is over, otherwise false.
*/
bool_t ticTacToeIsGameOver(
const std::map<uint8_t, enum TicTacToeTileState> board
);
/**
* Returns the score / value of a given board for the given player. Mostly
* used by the AI to determine whether a given board is better or worse than