public bool IsMoveLegal(Move move) { if (((1ul << move.From) & Occupancy[ColorToMove]) == 0) { return(false); } var fromPiece = PieceTable[move.From]; switch (fromPiece) { case Piece.Pawn: return(PawnOperator.IsMoveLegal(this, move)); case Piece.Knight: return(KnightOperator.IsMoveLegal(this, move)); case Piece.Bishop: return(BishopOperator.IsMoveLegal(this, move)); case Piece.Rook: return(RookOperator.IsMoveLegal(this, move)); case Piece.Queen: return(QueenOperator.IsMoveLegal(this, move)); case Piece.King: return(KingOperator.IsMoveLegal(this, move)); } return(false); }
public static int Evaluate(BoardState board, int color, int openingPhase, int endingPhase, ref ulong fieldsAttackedByColor) { var mobility = KnightOperator.GetMobility(board, color, ref fieldsAttackedByColor) + BishopOperator.GetMobility(board, color, ref fieldsAttackedByColor) + RookOperator.GetMobility(board, color, ref fieldsAttackedByColor) + QueenOperator.GetMobility(board, color, ref fieldsAttackedByColor); var mobilityOpeningScore = mobility * EvaluationConstants.Mobility; return(TaperedEvaluation.AdjustToPhase(mobilityOpeningScore, 0, openingPhase, endingPhase)); }
public int GetAvailableCaptureMoves(Span <Move> moves) { var movesCount = PawnOperator.GetAvailableCaptureMoves(this, moves, 0); movesCount = KnightOperator.GetAvailableCaptureMoves(this, moves, movesCount); movesCount = BishopOperator.GetAvailableCaptureMoves(this, moves, movesCount); movesCount = RookOperator.GetAvailableCaptureMoves(this, moves, movesCount); movesCount = QueenOperator.GetAvailableCaptureMoves(this, moves, movesCount); movesCount = KingOperator.GetAvailableCaptureMoves(this, moves, movesCount); return(movesCount); }
public int GetQuietMoves(Span <Move> moves, int offset, ulong evasionMask) { var movesCount = PawnOperator.GetQuietMoves(this, moves, offset, evasionMask); movesCount = KnightOperator.GetQuietMoves(this, moves, movesCount, evasionMask); movesCount = BishopOperator.GetQuietMoves(this, moves, movesCount, evasionMask); movesCount = RookOperator.GetQuietMoves(this, moves, movesCount, evasionMask); movesCount = QueenOperator.GetQuietMoves(this, moves, movesCount, evasionMask); movesCount = KingOperator.GetQuietMoves(this, moves, movesCount); return(movesCount); }
public int GetLoudMoves(Span <Move> moves, int offset) { var movesCount = PawnOperator.GetLoudMoves(this, moves, offset); movesCount = KnightOperator.GetLoudMoves(this, moves, movesCount); movesCount = BishopOperator.GetLoudMoves(this, moves, movesCount); movesCount = RookOperator.GetLoudMoves(this, moves, movesCount); movesCount = QueenOperator.GetLoudMoves(this, moves, movesCount); movesCount = KingOperator.GetLoudMoves(this, moves, movesCount); return(movesCount); }
public static int Evaluate(BoardState board, int color, int openingPhase, int endingPhase, ref ulong fieldsAttackedByColor) { var(knightCenter, knightOutside) = KnightOperator.GetMobility(board, color, ref fieldsAttackedByColor); var(bishopCenter, bishopOutside) = BishopOperator.GetMobility(board, color, ref fieldsAttackedByColor); var(rookCenter, rookOutside) = RookOperator.GetMobility(board, color, ref fieldsAttackedByColor); var(queenCenter, queenOutside) = QueenOperator.GetMobility(board, color, ref fieldsAttackedByColor); var centerMobility = knightCenter + bishopCenter + rookCenter + queenCenter; var centerMobilityScore = centerMobility * EvaluationConstants.CenterMobilityModifier; var outsideMobility = knightOutside + bishopOutside + rookOutside + queenOutside; var outsideMobilityScore = outsideMobility * EvaluationConstants.OutsideMobilityModifier; var openingScore = centerMobilityScore + outsideMobilityScore; return(TaperedEvaluation.AdjustToPhase(openingScore, 0, openingPhase, endingPhase)); }