bool BoardEvaluator::IsFinished(Board &board, Colour *winningColour) { for (unsigned int i = 0; i < WIDTH; i++) { for (unsigned int j = 0; j < HEIGHT; j++) { Counter *counter = board.Space(i, j); if (counter != NULL) { // creating the dirctions to be searched in. North north(i, j); South south(i, j); East east(i, j); West west(i, j); NorthEast northEast(i, j); NorthWest northWest(i, j); SouthEast southEast(i, j); SouthWest southWest(i, j); bool retVal = false; Colour retCol = NULL_COLOUR; unsigned int conLength = CONNECT_LENGTH; Colour colour = (Colour)counter->GetColour(); if (RecursiveSearch(colour, &north, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &south, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &east, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &west, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &northEast, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &northWest, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &southEast, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &southWest, conLength - 1, board)) { retCol = colour; retVal = true; } if (retVal) { *winningColour = retCol; return true; } } } } return false; }