/// <summary> /// Calculates and returns the current score of the board for a given player /// The score is calculated as the number of allied discs minus the number of opponnent discs. /// </summary> /// <param name="board">The game board</param> /// <param name="color">The player color</param> /// <returns>The board-player score</returns> public static int Score(Disc[,] board, Disc color) { Contract.Requires(!color.IsEmpty()); int score = CountDiscs(board, Disc.White) - CountDiscs(board, Disc.Black); if (color == Disc.Black) { score *= -1; } return(score); }
/// <summary> /// Calculates and returns the current score of the board for a given player /// The score is calculated as the number of allied discs minus the number of opponnent discs. /// </summary> /// <param name="board">The game board</param> /// <param name="color">The player color</param> /// <returns>The board-player score</returns> public static int Score(Disc[,] board, Disc color) { Contract.Requires(!color.IsEmpty()); int score = CountDiscs(board, Disc.White) - CountDiscs(board, Disc.Black); if (color == Disc.Black) score *= -1; return score; }