Exemple #1
0
        private void ApplyMoveEffects()
        {
            //PlayerWaiting is the player who made the last move

            //Check or mate
            if (GamePosition.Check)
            {
                bool MovedIsHuman = PlayerWaiting is HumanPlayer;
                bool LostIsHuman  = PlayerToMove is HumanPlayer;
                int  ColorWin     = (PlayerWaiting == PlayerWhite) ? Color.White : Color.Black;
                if (GamePosition.Checkmate)
                {
                    BoardView.Checkmate(MovedIsHuman, LostIsHuman, ColorWin);
                }
                else
                {
                    BoardView.Check(true);
                }
            }
            //Stalemate
            else if (GamePosition.Stalemate)
            {
                BoardView.Stalemate();
            }
            //Draw by fifty-move rule
            else
            {
                if (GamePosition.MovesFiftyRuleCount >= 50)
                {
                    BoardView.FiftyMoveRule();
                }
            }
            if (Global.USE_TEST)
            {
                if (PlayerWaiting is EnginePlayer)
                {
                    EnginePlayer EP = (EnginePlayer)(PlayerWaiting);
                    Test.ShowStats("Time: " + EP.TEST_ThinkTime + "\n");
                    Test.ShowStats("Total nodes considered:    " + EP.TEST_Nodes + " (" + Math.Round(EP.TEST_Nodes / EP.TEST_ThinkTime.TotalSeconds) + " n/s)\n");
                    Test.ShowStats("Total positions evaluated: " + EP.TEST_Evaluated.ToString() + " (" + Math.Round(EP.TEST_Evaluated / EP.TEST_ThinkTime.TotalSeconds) + " n/s)\n");
                    Test.ShowStats("LegalMoves calculated " + EP.TEST_LegalMovesCallCount.ToString() + " times\n");
                    //Test.ShowStats("Attacks called " + EP.TEST_AttacksCallCount.ToString() + " times\n");
                    //Test.ShowStats("\n");
                }
                Test.ShowStats("Moves fifty-rule: " + GamePosition.MovesFiftyRuleCount.ToString() + "\n\n");
            }

            int WhiteMaterialAdvantage = CountMaterial();

            BoardView.SetMaterial(WhiteMaterialAdvantage, -WhiteMaterialAdvantage);
        }