Пример #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}.");
        }
Пример #2
0
        private static IEnumerable <MoveTestCase> GetTestCases(Color color, ushort squareIndex)
        {
            var moveSet      = GetPawnShift(squareIndex, color);
            var setSquares   = MovingPieceService.GetSetBits(moveSet);
            var permutations = MovingPieceService.GetAllPermutationsOfSetBits(setSquares, 0, 0);
            var testCases    = new List <MoveTestCase>();

            foreach (var block in permutations)
            {
                var obstructionBoards = GetMovesFromObstructions(color, block, squareIndex);

                testCases.Add(new MoveTestCase(squareIndex, color, 0, obstructionBoards.Occupancy,
                                               obstructionBoards.MoveBoard));
            }

            return(testCases);
        }