X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.h;h=2b44ef329f33dca4e3eb7bda87533f2b67d5ad40;hp=3d0ffb85d9d3c089d22dbde8951df4955f64f33c;hb=0c1f119069bf915b85126159d4865c4bcc532239;hpb=d8f683760c9eb6d2c4714ec83e717dd2143de55c diff --git a/src/position.h b/src/position.h index 3d0ffb85..2b44ef32 100644 --- a/src/position.h +++ b/src/position.h @@ -90,6 +90,7 @@ public: Square ep_square() const; bool empty(Square s) const; template int count(Color c) const; + template int count() const; template const Square* squares(Color c) const; template Square square(Color c) const; @@ -108,7 +109,7 @@ public: // Attacks to/from a given square Bitboard attackers_to(Square s) const; Bitboard attackers_to(Square s, Bitboard occupied) const; - Bitboard attacks_from(Piece pc, Square s) const; + Bitboard attacks_from(PieceType pt, Square s) const; template Bitboard attacks_from(Square s) const; template Bitboard attacks_from(Square s, Color c) const; Bitboard slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const; @@ -135,7 +136,7 @@ public: void undo_null_move(); // Static Exchange Evaluation - bool see_ge(Move m, Value value) const; + bool see_ge(Move m, Value value = VALUE_ZERO) const; // Accessing hash keys Key key() const; @@ -154,6 +155,7 @@ public: int rule50_count() const; Score psq_score() const; Value non_pawn_material(Color c) const; + Value non_pawn_material() const; // Position consistency check, for debugging bool pos_is_ok(int* failedStep = nullptr) const; @@ -236,6 +238,10 @@ template inline int Position::count(Color c) const { return pieceCount[make_piece(c, Pt)]; } +template inline int Position::count() const { + return pieceCount[make_piece(WHITE, Pt)] + pieceCount[make_piece(BLACK, Pt)]; +} + template inline const Square* Position::squares(Color c) const { return pieceList[make_piece(c, Pt)]; } @@ -267,18 +273,19 @@ inline Square Position::castling_rook_square(CastlingRight cr) const { template inline Bitboard Position::attacks_from(Square s) const { + assert(Pt != PAWN); return Pt == BISHOP || Pt == ROOK ? attacks_bb(s, byTypeBB[ALL_PIECES]) : Pt == QUEEN ? attacks_from(s) | attacks_from(s) - : StepAttacksBB[Pt][s]; + : PseudoAttacks[Pt][s]; } template<> inline Bitboard Position::attacks_from(Square s, Color c) const { - return StepAttacksBB[make_piece(c, PAWN)][s]; + return PawnAttacks[c][s]; } -inline Bitboard Position::attacks_from(Piece pc, Square s) const { - return attacks_bb(pc, s, byTypeBB[ALL_PIECES]); +inline Bitboard Position::attacks_from(PieceType pt, Square s) const { + return attacks_bb(pt, s, byTypeBB[ALL_PIECES]); } inline Bitboard Position::attackers_to(Square s) const { @@ -330,6 +337,10 @@ inline Value Position::non_pawn_material(Color c) const { return st->nonPawnMaterial[c]; } +inline Value Position::non_pawn_material() const { + return st->nonPawnMaterial[WHITE] + st->nonPawnMaterial[BLACK]; +} + inline int Position::game_ply() const { return gamePly; }