Example #1
0
        // Takes ownership of all arrays passed to it; they should not be changed after the position is created.
        public Position(Piece[] pieceSquares, Color sideToMove, ulong castlingRights, ulong enPassant, int fiftyMoveCounter, int fullMove)
        {
            _pieceBitboards = new BitboardArray();
            _squares        = new PieceSquareArray();
            // safer to go by the length the PieceSquareArray, because the Piece[] will always error on index out of bounds
            for (int i = 0; i < _squares.Length; i++)
            {
                _squares[i] = pieceSquares[i];
            }

            PopulatePieceBitboardsFromSquares(ref _pieceBitboards, pieceSquares);

            _occupiedWhite = CalculateOccupied(Color.White);
            _occupiedBlack = CalculateOccupied(Color.Black);

            _occupied = _occupiedWhite | _occupiedBlack;

            Parent = null;

            SideToMove     = sideToMove;
            CastlingRights = castlingRights;
            EnPassant      = enPassant;

            FiftyMoveCounter = fiftyMoveCounter;
            GamePly          = GamePlyFromFullMove(fullMove, sideToMove);
            _historyPly      = 0;

            RepetitionNumber = 1;

            ZobristHash = ZobristHashing.CalculateFullHash(this);
        }
Example #2
0
 public Position()
 {
     _pieceBitboards = new BitboardArray();
     _squares        = new PieceSquareArray();
 }
Example #3
0
 // would need to copy the contents if this were an array
 private void CopySquares(ref PieceSquareArray ret)
 {
     ret = _squares;
 }