Пример #1
0
        public void ShouldParseFromBoardMove(string @from, string to, DefaultActions moveType, string expectedSan)
        {
            var game = ChessFactory.NewChessGame();
            var move = BoardMove.Create(from.ToBoardLocation(), to.ToBoardLocation(), (int)moveType);

            Assert.That(StandardAlgebraicNotation.ParseFromGameMove(game.BoardState, move).ToNotation(), Is.EqualTo(expectedSan));
        }
Пример #2
0
 public Move[] ToMoveList(params LocatedItem <ChessPieceEntity>[] locatedItems)
 {
     return(locatedItems
            .SelectMany(i => i.Paths.FlattenMoves())
            .Select(m => new Move
     {
         Coord = $"{m.ToChessCoords()}",
         SAN = StandardAlgebraicNotation.ParseFromGameMove(Game.BoardState, m, true).ToNotation()
     }).ToArray());
 }
        public void Should_put_plus_on_end_of_moves_that_cause_check()
        {
            // TODO: Better way to check this, than using a full board.
            var builder = new ChessBoardBuilder()
                          .Board("....rrk." +
                                 ".b...pp." +
                                 ".n...q.p" +
                                 "..p.N..." +
                                 ".pB....." +
                                 ".......P" +
                                 "PP...PP." +
                                 "R..QR.K."
                                 );

            var game      = ChessFactory.CustomChessGame(builder.ToGameSetup());
            var from      = "C4".ToBoardLocation();
            var piece     = game.BoardState.GetItem(from);
            var boardMove = piece.Paths.FindMove(from, "f7".ToBoardLocation());
            var san       = StandardAlgebraicNotation.ParseFromGameMove(game.BoardState, boardMove, true);

            san.ToNotation().ShouldBe("Bxf7+");
        }