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));
        }
Esempio n. 3
0
 public static PossibleMove CaptureMove(SquareId from, SquareId to, SquareId?victim, bool moreCapturesAvailable)
 {
     return(new PossibleMove(from, to, victim, moreCapturesAvailable));
 }
Esempio n. 4
0
 public Square(SquareId id, Piece piece, BoardPosition board)
 {
     Id     = id;
     Piece  = piece;
     _board = board;
 }
Esempio n. 5
0
 public static PossibleMove NormalMove(SquareId from, SquareId to) => new PossibleMove(from, to, null, false);
Esempio n. 6
0
 private PossibleMove(SquareId from, SquareId to, SquareId?victim, bool moreCapturesAvailable)
     : base(from, to, victim is not null)
 {
     MoreCapturesAvailable = moreCapturesAvailable;
     Victim = victim;
 }
Esempio n. 7
0
 protected Move(SquareId from, SquareId to, bool isCapture)
 {
     From      = from;
     To        = to;
     IsCapture = isCapture;
 }
Esempio n. 8
0
 public Square this[SquareId n] {
     get => _squares[n.Value - 1];
Esempio n. 9
0
 /// <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;