Пример #1
0
        public void Undo(IBoard board, IHistoryItem toUndo, IHistoryItem lastMoveBeforeUndo)
        {
            var minBoard = board.ToMinified();

            var minToUndo = new HistoryItemMinified();

            minToUndo.Minify(toUndo, board);

            HistoryItemMinified minLastMove = null;

            if (lastMoveBeforeUndo != null)
            {
                minLastMove = new HistoryItemMinified();
                minLastMove.Minify(lastMoveBeforeUndo, board);
            }

            minBoard = ChainOfRules.UndoRule(minBoard, minToUndo, minLastMove);
            minBoard.ToMaximized(board);
        }
Пример #2
0
        public IPlayer MakeMove(IBoard board, IHistoryItem move)
        {
            var minBoard = board.ToMinified();

            var minMove = new HistoryItemMinified();

            minMove.Minify(move, board);

            minBoard = MakeMove(minBoard, minMove);
            minBoard.ToMaximized(board);
            minMove.Maximize(move);

            if (minBoard.Player1PiecesCount == 0)
            {
                return(board.Player1);
            }

            if (minBoard.Player2PiecesCount == 0)
            {
                return(board.Player2);
            }
            return(null);
        }