Some Logic tidy
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user