private IEnumerable <Square> AllLoopPositions()
 {
     if (_restrictedTo is not null)
     {
         yield return(_board[_restrictedTo]);
     }
     else
     {
         for (int i = 1; i <= _board.NrOfPlayableSquares; i++)
         {
             var squareId = new SquareId(i);
             if (_board[squareId].Color == _currentTurn)
             {
                 yield return(_board[squareId]);
             }
         }
     }
 }
        public static PossibleMoveCalculator ForChainCaptures(BoardPosition board, SquareId from, GameSettings settings)
        {
            var currentTurn = board[from].Color ?? throw new ManualValidationException("Invalid move.");

            return(new PossibleMoveCalculator(board, settings, currentTurn, from, 1));
        }
Exemple #3
0
 public static PossibleMove CaptureMove(SquareId from, SquareId to, SquareId?victim, bool moreCapturesAvailable)
 {
     return(new PossibleMove(from, to, victim, moreCapturesAvailable));
 }
Exemple #4
0
 public Square(SquareId id, Piece piece, BoardPosition board)
 {
     Id     = id;
     Piece  = piece;
     _board = board;
 }
Exemple #5
0
 public static PossibleMove NormalMove(SquareId from, SquareId to) => new PossibleMove(from, to, null, false);
Exemple #6
0
 private PossibleMove(SquareId from, SquareId to, SquareId?victim, bool moreCapturesAvailable)
     : base(from, to, victim is not null)
 {
     MoreCapturesAvailable = moreCapturesAvailable;
     Victim = victim;
 }
Exemple #7
0
 protected Move(SquareId from, SquareId to, bool isCapture)
 {
     From      = from;
     To        = to;
     IsCapture = isCapture;
 }
 public Square this[SquareId n] {
     get => _squares[n.Value - 1];
 /// <summary>
 /// The square at (x, y).
 /// The top left square is (0, 0).
 /// </summary>
 public Square? this[int x, int y] => IsPlayable(x, y) ? this[SquareId.FromPosition(x, y, Size)] : null;