Esempio n. 1
0
        public override string ToString()
        {
            var pieceFile         = MovingPieceService.FileFromIdx(SquareIndex);
            var pawnDescription   = $"{Color.AsString()}";
            var pieceDescription  = $"Piece";
            var pawnPlacement     = $"on {DisplayHelpers.ToSquareString(SquareIndex)} ";
            var expectedIndexes   = MovingPieceService.GetSetBits(Expected);
            var playerOccupancy   = MovingPieceService.GetSetBits(PlayerObstructions);
            var opponentOccupancy = MovingPieceService.GetSetBits(OpponentObstructions);
            var strMoves          =
                expectedIndexes.Any()
                    ? $"move to {string.Join(", ", expectedIndexes.Select(DisplayHelpers.ToSquareString))}"
                    : "[no moves expected]";
            var strPlayerOccupancy =
                playerOccupancy.Any()
                    ? string.Join(", ", playerOccupancy.Select(DisplayHelpers.ToSquareString))
                    : "[no player pieces]";
            var strOpponentOccupancy =
                opponentOccupancy.Any()
                    ? string.Join(", ", opponentOccupancy.Select(DisplayHelpers.ToSquareString))
                    : "[no opponent pieces]";
            var attackedOpponentPieces = opponentOccupancy.Where(x => MovingPieceService.FileFromIdx(x) != pieceFile);
            var strAttack = attackedOpponentPieces.Any()
                ? $"- Attack pieces on {string.Join(", ", attackedOpponentPieces.Select(DisplayHelpers.ToSquareString))}"
                : "[no attacked pieces]";

            return($"{pawnDescription} {pieceDescription} on {pawnPlacement} should be able to:{Environment.NewLine}" +
                   $"{strMoves}{Environment.NewLine}" +
                   $"{strAttack}{Environment.NewLine}" +
                   $"when players pieces are at {strPlayerOccupancy} and opponent pieces are at {strOpponentOccupancy}.");
        }
Esempio n. 2
0
        public void RookMovesShouldBeInitialized(ushort squareIndex)
        {
            var rank     = MovingPieceService.RankFromIdx(squareIndex);
            var file     = MovingPieceService.FileFromIdx(squareIndex);
            var rankFill = (ulong)0xff << (rank * 8);
            var fileFill = (ulong)0x101010101010101 << file;
            var boardVal = MovingPieceService.GetBoardValueOfIndex(squareIndex);

            var mask   = (rankFill | fileFill) ^ boardVal;
            var actual = BitBoard.GetPseudoLegalMoves(squareIndex, Piece.Rook, Color.Black, 0);

            Assert.AreEqual(mask, actual);
        }