Skip to content

Commit

Permalink
Retire Phase type
Browse files Browse the repository at this point in the history
Following the previous commit, retire the associated Phase type for tapered evaluations

Non-regression STC:
LLR:  3.00/2.94<-6.00, 0.00> Elo diff: 2.75 [-0.91, 6.41] (95%)
Games: 6441 W: 744 L: 693 D: 5004 Draw ratio: 77.7%
Pntl: [23, 469, 2197, 496, 35]

No functional change
  • Loading branch information
ruicoelhopedro committed May 10, 2024
1 parent c05147d commit 61f586e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
13 changes: 1 addition & 12 deletions src/Position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ Board::Board()


Board::Board(std::string fen)
: m_hash(0),
m_phase(Phases::Total)
: m_hash(0)
{
auto c = fen.cbegin();

Expand Down Expand Up @@ -499,22 +498,18 @@ bool Board::is_valid() const
return false;

// Material and phase evaluation
uint8_t phase = Phases::Total;
NNUE::Accumulator acc[2];
for (PieceType piece : { PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING })
for (Turn turn : { WHITE, BLACK })
{
Bitboard bb = get_pieces(turn, piece);
phase -= bb.count() * Phases::Pieces[piece];
while (bb)
{
Square s = bb.bitscan_forward_reset();
acc[WHITE].push(piece, s, m_king_sq[WHITE], turn, WHITE);
acc[BLACK].push(piece, s, m_king_sq[BLACK], turn, BLACK);
}
}
if (phase != m_phase)
return false;
if (acc[WHITE] != m_acc[WHITE] || acc[BLACK] != m_acc[BLACK])
return false;

Expand Down Expand Up @@ -660,12 +655,6 @@ Score Board::see(Move move, Score threshold) const
}


uint8_t Board::phase() const
{
return m_phase;
}


bool Board::legal(Move move) const
{
// Same source and destination squares?
Expand Down
6 changes: 0 additions & 6 deletions src/Position.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Board
Hash m_hash;
Bitboard m_checkers;
NNUE::Accumulator m_acc[NUM_COLORS];
uint8_t m_phase;
Piece m_board_pieces[NUM_SQUARES];

protected:
Expand Down Expand Up @@ -484,7 +483,6 @@ class Board
m_board_pieces[square] = get_piece(piece, turn);
m_acc[WHITE].push(piece, square, m_king_sq[WHITE], turn, WHITE);
m_acc[BLACK].push(piece, square, m_king_sq[BLACK], turn, BLACK);
m_phase -= Phases::Pieces[piece];
}


Expand All @@ -495,7 +493,6 @@ class Board
m_board_pieces[square] = NO_PIECE;
m_acc[WHITE].pop(piece, square, m_king_sq[WHITE], turn, WHITE);
m_acc[BLACK].pop(piece, square, m_king_sq[BLACK], turn, BLACK);
m_phase += Phases::Pieces[piece];
}


Expand Down Expand Up @@ -654,9 +651,6 @@ class Board
Score see(Move move, Score threshold = 0) const;


uint8_t phase() const;


bool legal(Move move) const;


Expand Down
16 changes: 0 additions & 16 deletions src/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,6 @@ enum ScoreType : Score
SCORE_NONE = 32002
};


namespace Phases
{
constexpr int Pawn = 0;
constexpr int Knight = 1;
constexpr int Bishop = 1;
constexpr int Rook = 2;
constexpr int Queen = 4;
constexpr int King = 0;
constexpr int Pieces[NUM_PIECE_TYPES] = { Pawn, Knight, Bishop, Rook, Queen, King };
constexpr int Total = 16 * Pawn + 4 * Knight + 4 * Bishop + 4 * Rook + 2 * Queen + 2 * King;

constexpr int MgLimit = 4;
constexpr int EgLimit = 19;
}

constexpr Score ScoreToCp = 200;

constexpr Score PawnValue( 125);
Expand Down

0 comments on commit 61f586e

Please sign in to comment.