/// <summary> /// Removes en passant piece from the specified bitboard. /// </summary> /// <param name="bitboard">The bitboard.</param> /// <param name="enemyColor">The enemy color.</param> /// <param name="fieldLSB">The bitboard with set field.</param> private void RemoveEnPassantPiece(Bitboard bitboard, Color enemyColor, ulong fieldLSB) { var enPassantPiece = Color == Color.White ? fieldLSB >> 8 : fieldLSB << 8; bitboard.Pieces[FastArray.GetPieceIndex(enemyColor, PieceType.Pawn)] &= ~enPassantPiece; bitboard.Occupancy[(int)enemyColor] ^= enPassantPiece; IncrementalMaterial.RemovePiece(bitboard, enemyColor, PieceType.Pawn); IncrementalPosition.RemovePiece(bitboard, enemyColor, PieceType.Pawn, enPassantPiece); IncrementalZobrist.AddOrRemovePiece(enemyColor, PieceType.Pawn, enPassantPiece, bitboard); }
/// <summary> /// Calculates a promotion move. /// </summary> /// <param name="bitboard">The bitboard.</param> public override void CalculateMove(Bitboard bitboard) { var from = BitPositionConverter.ToULong(From); var to = BitPositionConverter.ToULong(To); if (KillMove) { CalculateKill(bitboard, ColorOperations.Invert(Color), to); } CalculatePieceMove(bitboard, Piece, from, PromotionPiece, to); IncrementalMaterial.RemovePiece(bitboard, Color, Piece); IncrementalMaterial.AddPiece(bitboard, Color, PromotionPiece); }
/// <summary> /// Removes killed piece from the specified bitboard. /// </summary> /// <param name="bitboard">The bitboard.</param> /// <param name="enemyColor">The enemy color.</param> /// <param name="fieldLSB">The bitboard with set field.</param> protected void CalculateKill(Bitboard bitboard, Color enemyColor, ulong fieldLSB) { for (var piece = 0; piece < 6; piece++) { var index = FastArray.GetPieceIndex(enemyColor, (PieceType)piece); if ((bitboard.Pieces[index] & fieldLSB) != 0) { bitboard.Pieces[index] &= ~fieldLSB; bitboard.Occupancy[(int)enemyColor] &= ~fieldLSB; IncrementalMaterial.RemovePiece(bitboard, enemyColor, (PieceType)piece); IncrementalPosition.RemovePiece(bitboard, enemyColor, (PieceType)piece, fieldLSB); IncrementalZobrist.AddOrRemovePiece(enemyColor, (PieceType)piece, fieldLSB, bitboard); bitboard.ReversibleMoves = 0; break; } } }