void HandleWinner()
        {
            byte       winnerTile     = Game.GetWinner(board);
            Storyboard winnerBannerIn = this.FindResource("WinnerBannerIn") as Storyboard;
            Storyboard gameOptionsOut = this.FindResource("GameOptionsOut") as Storyboard;

            winnerBannerIn.Begin();
            gameOptionsOut.Begin();
            string player1Text;
            string player2Text;
            string winType = "beat";
            string scoreText;

            if (winnerTile == Game.White || winnerTile == Game.Tie)
            {
                player1Text = Player1Name.Text;
                player2Text = Player2Name.Text;
                scoreText   = Game.GetScore(board, Game.White).ToString() + "-" + Game.GetScore(board, Game.Black).ToString();
            }
            else // winner == Game.Black
            {
                player1Text = Player2Name.Text;
                player2Text = Player1Name.Text;
                scoreText   = Game.GetScore(board, Game.Black).ToString() + "-" + Game.GetScore(board, Game.White).ToString();
            }
            WinnerBannerScore.Text = scoreText;
            if (winnerTile == Game.Tie)
            {
                WinnerBannerHeading.Text = "It's a tie!";
                winType = "tied with";
            }
            WinnerBannerPlayer1.Text = player1Text;
            WinnerBannerPlayer2.Text = player2Text;
            WinnerBannerWinType.Text = winType;
            WinnerBannerScore.Text   = scoreText;
            // Write highscores.
            using (StreamWriter writer = new StreamWriter("highscores.txt", append: true))
            {
                string[] gameInfo = { player1Text, winType, player2Text, scoreText };
                writer.WriteLine(string.Join(",", gameInfo));
            }
        }
        void HandleNextMove(Tuple <int, int> move)
        {
            if (Game.GetWinner(board) == Game.Empty)
            {
                Player currentPlayer = Player.GetPlayerFromTurn(turn, player1, player2);
                List <Tuple <int, int> > validMoves = Game.GetValidMoves(board, currentPlayer.Tile);
                if (validMoves.Count > 0 && move != null)
                {
                    if (validMoves.Contains(move))
                    {
                        Game.MakeMove(board, move, currentPlayer.Tile);
                        boardHistories.Add(board.Clone() as byte[, ]);
                        turn++;
                        RenderBoard(board);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    turn++;
                }

                if (Game.GetWinner(board) != Game.Empty)
                {
                    HandleWinner();
                }
                Player nextPlayer = Player.GetPlayerFromTurn(turn, player1, player2);
                if (nextPlayer.Mode != Player.Modes.Human)
                {
                    HandleAIMove();
                }
            }
        }