Esempio n. 1
0
        private void BoardView_AskForUndo(object sender, EventArgs e)
        {
            if (PlayerToMove.IsThinking)
            {
                return;
            }
            if (GamePosition.GameFinished)
            {
                return;
            }

            int HowManyHalfMoves = (PlayerWaiting is EnginePlayer) ? 2 : 1;

            for (int i = 0; i < HowManyHalfMoves; i++)
            {
                int?MoveToUndo = GamePosition.LastMove;
                if (MoveToUndo == null)
                {
                    //No moves handler
                    return;
                }
                GamePosition.UnMake();
                BoardView.UndoMove((int)MoveToUndo);
            }

            int WhiteMaterialAdvantage = CountMaterial();

            BoardView.SetMaterial(WhiteMaterialAdvantage, -WhiteMaterialAdvantage);
        }