예제 #1
0
        public void KingShouldNotMoveToBeCaptured()
        {
            // In local game king moved to f6 and was captured

            // 8    | K
            // 7   N|
            // 6    |
            // 5 PP |  K
            // 4  > |RN
            // 3    |
            // 2   R|
            // 1    |
            //  ABCD EFGH
            var player = new Logic(true);

            player.Phase       = GamePhase.EndGame;
            player.TurnCount   = 20;
            player.SearchDepth = 3;

            var previousMove = new MoveImplementation()
            {
                StartPosition = "c4",
                EndPosition   = "e4"
            };

            player.LatestOpponentMove = previousMove;
            player.GameHistory.Add(previousMove);

            var board  = new Board();
            var pieces = new List <PieceBase>
            {
                new Pawn(true, "b5"),
                new Pawn(false, "c5"),
                new Rook(true, "d2"),
                new Rook(false, "e4"),
                new Knight(true, "f4"),
                new Knight(false, "d7")
            };

            board.AddNew(pieces);
            //
            var blackKing = new King(false, "f8");

            board.AddNew(blackKing);

            var whiteKing = new King(true, "g5");

            board.AddNew(whiteKing);

            board.Kings = (whiteKing, blackKing);

            player.Board = new Board(board);

            var playerMove = player.CreateMove();

            playerMove.Move.EndPosition.ShouldNotBe("f6");
        }
예제 #2
0
        public static IMove ToCommon(Move grpcMove)
        {
            var move = new MoveImplementation()
            {
                Castling        = grpcMove.Castling,
                Check           = grpcMove.Check,
                CheckMate       = grpcMove.CheckMate,
                StartPosition   = grpcMove.StartPosition,
                EndPosition     = grpcMove.EndPosition,
                PromotionResult = (PromotionPieceType)grpcMove.PromotionResult
            };

            return(move);
        }
예제 #3
0
        public static IMove ToCommon(Move grpcMove)
        {
            if (grpcMove.Chess == null)
            {
                throw new ArgumentException($"Expected chess parameter was null.", nameof(grpcMove));
            }
            var chessMove = grpcMove.Chess;

            var move = new MoveImplementation()
            {
                Castling        = chessMove.Castling,
                Check           = chessMove.Check,
                CheckMate       = chessMove.CheckMate,
                StartPosition   = chessMove.StartPosition,
                EndPosition     = chessMove.EndPosition,
                PromotionResult = (PromotionPieceType)chessMove.PromotionResult
            };

            return(move);
        }