private static int ScoreWindow(TicTacToeGame game, TokenWindow <TicTacToeToken> tokenWindow, Player <TicTacToeToken> player) { Player <TicTacToeToken> otherPlayer = game.GetOtherPlayer(player); TicTacToeToken playerToken = player.Token; TicTacToeToken otherPlayerToken = otherPlayer.Token; int score = 0; { Coordinate center = new Coordinate(game.Width / 2 + 1, game.Height / 2 + 1); if (tokenWindow.Pairs.Any(pair => pair.Item1 == center && pair.Item2 == playerToken)) { score += 10; } } return(score); }
public bool IsWinningTokenWindow(TokenWindow <TicTacToeToken> window) { return(window.Tokens.Distinct().Count() == 1 && window.Tokens.All(t => t != TicTacToeToken.Blank)); }