mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Remove Positions::xxx_count() functions
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
0d19437703
commit
d0e51bc0f0
4 changed files with 78 additions and 103 deletions
|
@ -212,19 +212,19 @@ KPKPScalingFunction::KPKPScalingFunction(Color c) : ScalingFunction(c) { }
|
|||
Value KXKEvaluationFunction::apply(const Position &pos) {
|
||||
|
||||
assert(pos.non_pawn_material(weakerSide) == Value(0));
|
||||
assert(pos.pawn_count(weakerSide) == Value(0));
|
||||
assert(pos.piece_count(weakerSide, PAWN) == Value(0));
|
||||
|
||||
Square winnerKSq = pos.king_square(strongerSide);
|
||||
Square loserKSq = pos.king_square(weakerSide);
|
||||
|
||||
Value result =
|
||||
pos.non_pawn_material(strongerSide) +
|
||||
pos.pawn_count(strongerSide) * PawnValueEndgame +
|
||||
pos.piece_count(strongerSide, PAWN) * PawnValueEndgame +
|
||||
mate_table(loserKSq) +
|
||||
distance_bonus(square_distance(winnerKSq, loserKSq));
|
||||
|
||||
if(pos.queen_count(strongerSide) > 0 || pos.rook_count(strongerSide) > 0 ||
|
||||
pos.bishop_count(strongerSide) > 1)
|
||||
if(pos.piece_count(strongerSide, QUEEN) > 0 || pos.piece_count(strongerSide, ROOK) > 0 ||
|
||||
pos.piece_count(strongerSide, BISHOP) > 1)
|
||||
// TODO: check for two equal-colored bishops!
|
||||
result += VALUE_KNOWN_WIN;
|
||||
|
||||
|
@ -238,12 +238,12 @@ Value KXKEvaluationFunction::apply(const Position &pos) {
|
|||
Value KBNKEvaluationFunction::apply(const Position &pos) {
|
||||
|
||||
assert(pos.non_pawn_material(weakerSide) == Value(0));
|
||||
assert(pos.pawn_count(weakerSide) == Value(0));
|
||||
assert(pos.piece_count(weakerSide, PAWN) == Value(0));
|
||||
assert(pos.non_pawn_material(strongerSide) ==
|
||||
KnightValueMidgame + BishopValueMidgame);
|
||||
assert(pos.bishop_count(strongerSide) == 1);
|
||||
assert(pos.knight_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(strongerSide) == 0);
|
||||
assert(pos.piece_count(strongerSide, BISHOP) == 1);
|
||||
assert(pos.piece_count(strongerSide, KNIGHT) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 0);
|
||||
|
||||
Square winnerKSq = pos.king_square(strongerSide);
|
||||
Square loserKSq = pos.king_square(weakerSide);
|
||||
|
@ -268,8 +268,8 @@ Value KPKEvaluationFunction::apply(const Position &pos) {
|
|||
|
||||
assert(pos.non_pawn_material(strongerSide) == Value(0));
|
||||
assert(pos.non_pawn_material(weakerSide) == Value(0));
|
||||
assert(pos.pawn_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Square wksq, bksq, wpsq;
|
||||
Color stm;
|
||||
|
@ -311,9 +311,9 @@ Value KPKEvaluationFunction::apply(const Position &pos) {
|
|||
Value KRKPEvaluationFunction::apply(const Position &pos) {
|
||||
|
||||
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(strongerSide) == 0);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 0);
|
||||
assert(pos.non_pawn_material(weakerSide) == 0);
|
||||
assert(pos.pawn_count(weakerSide) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 1);
|
||||
|
||||
Square wksq, wrsq, bksq, bpsq;
|
||||
int tempo = (pos.side_to_move() == strongerSide);
|
||||
|
@ -366,10 +366,10 @@ Value KRKPEvaluationFunction::apply(const Position &pos) {
|
|||
Value KRKBEvaluationFunction::apply(const Position &pos) {
|
||||
|
||||
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(strongerSide) == 0);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 0);
|
||||
assert(pos.non_pawn_material(weakerSide) == BishopValueMidgame);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.bishop_count(weakerSide) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
assert(pos.piece_count(weakerSide, BISHOP) == 1);
|
||||
|
||||
Value result = mate_table(pos.king_square(weakerSide));
|
||||
return (pos.side_to_move() == strongerSide)? result : -result;
|
||||
|
@ -382,10 +382,10 @@ Value KRKBEvaluationFunction::apply(const Position &pos) {
|
|||
Value KRKNEvaluationFunction::apply(const Position &pos) {
|
||||
|
||||
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(strongerSide) == 0);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 0);
|
||||
assert(pos.non_pawn_material(weakerSide) == KnightValueMidgame);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.knight_count(weakerSide) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
assert(pos.piece_count(weakerSide, KNIGHT) == 1);
|
||||
|
||||
Square defendingKSq = pos.king_square(weakerSide);
|
||||
Square nSq = pos.piece_list(weakerSide, KNIGHT, 0);
|
||||
|
@ -405,9 +405,9 @@ Value KRKNEvaluationFunction::apply(const Position &pos) {
|
|||
|
||||
Value KQKREvaluationFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);
|
||||
assert(pos.pawn_count(strongerSide) == 0);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 0);
|
||||
assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Square winnerKSq = pos.king_square(strongerSide);
|
||||
Square loserKSq = pos.king_square(weakerSide);
|
||||
|
@ -427,8 +427,8 @@ Value KQKREvaluationFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KBPKScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
|
||||
assert(pos.bishop_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(strongerSide) >= 1);
|
||||
assert(pos.piece_count(strongerSide, BISHOP) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) >= 1);
|
||||
|
||||
// No assertions about the material of weakerSide, because we want draws to
|
||||
// be detected even when the weaker side has some pawns.
|
||||
|
@ -479,10 +479,10 @@ ScaleFactor KBPKScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KQKRPScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);
|
||||
assert(pos.queen_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(strongerSide) == 0);
|
||||
assert(pos.rook_count(weakerSide) == 1);
|
||||
assert(pos.pawn_count(weakerSide) >= 1);
|
||||
assert(pos.piece_count(strongerSide, QUEEN) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 0);
|
||||
assert(pos.piece_count(weakerSide, ROOK) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) >= 1);
|
||||
|
||||
Square kingSq = pos.king_square(weakerSide);
|
||||
if(relative_rank(weakerSide, kingSq) <= RANK_2 &&
|
||||
|
@ -508,9 +508,9 @@ ScaleFactor KQKRPScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KRPKRScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(strongerSide) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 1);
|
||||
assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Square wksq = pos.king_square(strongerSide);
|
||||
Square wrsq = pos.piece_list(strongerSide, ROOK, 0);
|
||||
|
@ -613,9 +613,9 @@ ScaleFactor KRPKRScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(strongerSide) == 2);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 2);
|
||||
assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
|
||||
assert(pos.pawn_count(weakerSide) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 1);
|
||||
|
||||
Square wpsq1 = pos.piece_list(strongerSide, PAWN, 0);
|
||||
Square wpsq2 = pos.piece_list(strongerSide, PAWN, 1);
|
||||
|
@ -651,9 +651,9 @@ ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KPsKScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == Value(0));
|
||||
assert(pos.pawn_count(strongerSide) >= 2);
|
||||
assert(pos.piece_count(strongerSide, PAWN) >= 2);
|
||||
assert(pos.non_pawn_material(weakerSide) == Value(0));
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Bitboard pawns = pos.pawns(strongerSide);
|
||||
|
||||
|
@ -694,11 +694,11 @@ ScaleFactor KPsKScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
|
||||
assert(pos.bishop_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(strongerSide) == 1);
|
||||
assert(pos.piece_count(strongerSide, BISHOP) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 1);
|
||||
assert(pos.non_pawn_material(weakerSide) == BishopValueMidgame);
|
||||
assert(pos.bishop_count(weakerSide) == 1);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(weakerSide, BISHOP) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
|
||||
Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
|
||||
|
@ -748,11 +748,11 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
|
||||
assert(pos.bishop_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(strongerSide) == 1);
|
||||
assert(pos.piece_count(strongerSide, BISHOP) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 1);
|
||||
assert(pos.non_pawn_material(weakerSide) == KnightValueMidgame);
|
||||
assert(pos.knight_count(weakerSide) == 1);
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(weakerSide, KNIGHT) == 1);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
|
||||
Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
|
||||
|
@ -774,10 +774,10 @@ ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
|
|||
|
||||
ScaleFactor KNPKScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame);
|
||||
assert(pos.knight_count(strongerSide) == 1);
|
||||
assert(pos.pawn_count(strongerSide) == 1);
|
||||
assert(pos.piece_count(strongerSide, KNIGHT) == 1);
|
||||
assert(pos.piece_count(strongerSide, PAWN) == 1);
|
||||
assert(pos.non_pawn_material(weakerSide) == Value(0));
|
||||
assert(pos.pawn_count(weakerSide) == 0);
|
||||
assert(pos.piece_count(weakerSide, PAWN) == 0);
|
||||
|
||||
Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
|
||||
Square weakerKingSq = pos.king_square(weakerSide);
|
||||
|
@ -804,8 +804,8 @@ ScaleFactor KNPKScalingFunction::apply(const Position &pos) {
|
|||
ScaleFactor KPKPScalingFunction::apply(const Position &pos) {
|
||||
assert(pos.non_pawn_material(strongerSide) == Value(0));
|
||||
assert(pos.non_pawn_material(weakerSide) == Value(0));
|
||||
assert(pos.pawn_count(WHITE) == 1);
|
||||
assert(pos.pawn_count(BLACK) == 1);
|
||||
assert(pos.piece_count(WHITE, PAWN) == 1);
|
||||
assert(pos.piece_count(BLACK, PAWN) == 1);
|
||||
|
||||
Square wksq, bksq, wpsq;
|
||||
Color stm;
|
||||
|
|
|
@ -337,19 +337,19 @@ Value evaluate(const Position &pos, EvalInfo &ei, int threadID) {
|
|||
for (Color c = WHITE; c <= BLACK; c++)
|
||||
{
|
||||
// Knights
|
||||
for (int i = 0; i < pos.knight_count(c); i++)
|
||||
for (int i = 0; i < pos.piece_count(c, KNIGHT); i++)
|
||||
evaluate_knight(pos, pos.piece_list(c, KNIGHT, i), c, ei);
|
||||
|
||||
// Bishops
|
||||
for (int i = 0; i < pos.bishop_count(c); i++)
|
||||
for (int i = 0; i < pos.piece_count(c, BISHOP); i++)
|
||||
evaluate_bishop(pos, pos.piece_list(c, BISHOP, i), c, ei);
|
||||
|
||||
// Rooks
|
||||
for (int i = 0; i < pos.rook_count(c); i++)
|
||||
for (int i = 0; i < pos.piece_count(c, ROOK); i++)
|
||||
evaluate_rook(pos, pos.piece_list(c, ROOK, i), c, ei);
|
||||
|
||||
// Queens
|
||||
for(int i = 0; i < pos.queen_count(c); i++)
|
||||
for(int i = 0; i < pos.piece_count(c, QUEEN); i++)
|
||||
evaluate_queen(pos, pos.piece_list(c, QUEEN, i), c, ei);
|
||||
|
||||
// Special pattern: trapped bishops on a7/h7/a2/h2
|
||||
|
@ -427,7 +427,7 @@ Value evaluate(const Position &pos, EvalInfo &ei, int threadID) {
|
|||
{
|
||||
// Check for KBP vs KB with only a single pawn that is almost
|
||||
// certainly a draw or at least two pawns.
|
||||
bool one_pawn = (pos.pawn_count(WHITE) + pos.pawn_count(BLACK) == 1);
|
||||
bool one_pawn = (pos.piece_count(WHITE, PAWN) + pos.piece_count(BLACK, PAWN) == 1);
|
||||
sf = one_pawn ? ScaleFactor(8) : ScaleFactor(32);
|
||||
}
|
||||
else
|
||||
|
@ -569,7 +569,7 @@ namespace {
|
|||
if (v && (p.pawn_attacks(them, s) & p.pawns(us)))
|
||||
{
|
||||
bonus += v / 2;
|
||||
if ( p.knight_count(them) == 0
|
||||
if ( p.piece_count(them, KNIGHT) == 0
|
||||
&& (SquaresByColorBB[square_color(s)] & p.bishops(them)) == EmptyBoardBB)
|
||||
bonus += v;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ namespace {
|
|||
// from optimally tuned.
|
||||
Color them = opposite_color(us);
|
||||
|
||||
if ( p.queen_count(them) >= 1
|
||||
if ( p.piece_count(them, QUEEN) >= 1
|
||||
&& ei.kingAttackersCount[them] >= 2
|
||||
&& p.non_pawn_material(them) >= QueenValueMidgame + RookValueMidgame
|
||||
&& ei.kingAdjacentZoneAttacksCount[them])
|
||||
|
@ -781,7 +781,7 @@ namespace {
|
|||
{
|
||||
// We have a mate, unless the queen is pinned or there
|
||||
// is an X-ray attack through the queen.
|
||||
for (int i = 0; i < p.queen_count(them); i++)
|
||||
for (int i = 0; i < p.piece_count(them, QUEEN); i++)
|
||||
{
|
||||
from = p.piece_list(them, QUEEN, i);
|
||||
if ( bit_is_set(p.piece_attacks<QUEEN>(from), to)
|
||||
|
@ -994,7 +994,7 @@ namespace {
|
|||
// value if the other side has a rook or queen.
|
||||
if(square_file(s) == FILE_A || square_file(s) == FILE_H) {
|
||||
if(pos.non_pawn_material(them) == KnightValueMidgame
|
||||
&& pos.knight_count(them) == 1)
|
||||
&& pos.piece_count(them, KNIGHT) == 1)
|
||||
ebonus += ebonus / 4;
|
||||
else if(pos.rooks_and_queens(them))
|
||||
ebonus -= ebonus / 4;
|
||||
|
|
|
@ -255,13 +255,13 @@ MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
|
|||
return mi;
|
||||
}
|
||||
else if(pos.non_pawn_material(BLACK) == Value(0) &&
|
||||
pos.pawn_count(BLACK) == 0 &&
|
||||
pos.piece_count(BLACK, PAWN) == 0 &&
|
||||
pos.non_pawn_material(WHITE) >= RookValueEndgame) {
|
||||
mi->evaluationFunction = &EvaluateKXK;
|
||||
return mi;
|
||||
}
|
||||
else if(pos.non_pawn_material(WHITE) == Value(0) &&
|
||||
pos.pawn_count(WHITE) == 0 &&
|
||||
pos.piece_count(WHITE, PAWN) == 0 &&
|
||||
pos.non_pawn_material(BLACK) >= RookValueEndgame) {
|
||||
mi->evaluationFunction = &EvaluateKKX;
|
||||
return mi;
|
||||
|
@ -317,33 +317,33 @@ MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
|
|||
}
|
||||
|
||||
if(pos.non_pawn_material(WHITE) == BishopValueMidgame &&
|
||||
pos.bishop_count(WHITE) == 1 && pos.pawn_count(WHITE) >= 1)
|
||||
pos.piece_count(WHITE, BISHOP) == 1 && pos.piece_count(WHITE, PAWN) >= 1)
|
||||
mi->scalingFunction[WHITE] = &ScaleKBPK;
|
||||
if(pos.non_pawn_material(BLACK) == BishopValueMidgame &&
|
||||
pos.bishop_count(BLACK) == 1 && pos.pawn_count(BLACK) >= 1)
|
||||
pos.piece_count(BLACK, BISHOP) == 1 && pos.piece_count(BLACK, PAWN) >= 1)
|
||||
mi->scalingFunction[BLACK] = &ScaleKKBP;
|
||||
|
||||
if(pos.pawn_count(WHITE) == 0 &&
|
||||
if(pos.piece_count(WHITE, PAWN) == 0 &&
|
||||
pos.non_pawn_material(WHITE) == QueenValueMidgame &&
|
||||
pos.queen_count(WHITE) == 1 &&
|
||||
pos.rook_count(BLACK) == 1 && pos.pawn_count(BLACK) >= 1)
|
||||
pos.piece_count(WHITE, QUEEN) == 1 &&
|
||||
pos.piece_count(BLACK, ROOK) == 1 && pos.piece_count(BLACK, PAWN) >= 1)
|
||||
mi->scalingFunction[WHITE] = &ScaleKQKRP;
|
||||
else if(pos.pawn_count(BLACK) == 0 &&
|
||||
else if(pos.piece_count(BLACK, PAWN) == 0 &&
|
||||
pos.non_pawn_material(BLACK) == QueenValueMidgame &&
|
||||
pos.queen_count(BLACK) == 1 &&
|
||||
pos.rook_count(WHITE) == 1 && pos.pawn_count(WHITE) >= 1)
|
||||
pos.piece_count(BLACK, QUEEN) == 1 &&
|
||||
pos.piece_count(WHITE, ROOK) == 1 && pos.piece_count(WHITE, PAWN) >= 1)
|
||||
mi->scalingFunction[BLACK] = &ScaleKRPKQ;
|
||||
|
||||
if(pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) == Value(0)) {
|
||||
if(pos.pawn_count(BLACK) == 0) {
|
||||
assert(pos.pawn_count(WHITE) >= 2);
|
||||
if(pos.piece_count(BLACK, PAWN) == 0) {
|
||||
assert(pos.piece_count(WHITE, PAWN) >= 2);
|
||||
mi->scalingFunction[WHITE] = &ScaleKPsK;
|
||||
}
|
||||
else if(pos.pawn_count(WHITE) == 0) {
|
||||
assert(pos.pawn_count(BLACK) >= 2);
|
||||
else if(pos.piece_count(WHITE, PAWN) == 0) {
|
||||
assert(pos.piece_count(BLACK, PAWN) >= 2);
|
||||
mi->scalingFunction[BLACK] = &ScaleKKPs;
|
||||
}
|
||||
else if(pos.pawn_count(WHITE) == 1 && pos.pawn_count(BLACK) == 1) {
|
||||
else if(pos.piece_count(WHITE, PAWN) == 1 && pos.piece_count(BLACK, PAWN) == 1) {
|
||||
mi->scalingFunction[WHITE] = &ScaleKPKPw;
|
||||
mi->scalingFunction[BLACK] = &ScaleKPKPb;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
|
|||
for(c = WHITE, sign = 1; c <= BLACK; c++, sign = -sign) {
|
||||
|
||||
// No pawns makes it difficult to win, even with a material advantage:
|
||||
if(pos.pawn_count(c) == 0 &&
|
||||
if(pos.piece_count(c, PAWN) == 0 &&
|
||||
pos.non_pawn_material(c) - pos.non_pawn_material(opposite_color(c))
|
||||
<= BishopValueMidgame) {
|
||||
if(pos.non_pawn_material(c) == pos.non_pawn_material(opposite_color(c)))
|
||||
|
@ -366,7 +366,7 @@ MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
|
|||
else if(pos.non_pawn_material(c) < RookValueMidgame)
|
||||
mi->factor[c] = 0;
|
||||
else {
|
||||
switch(pos.bishop_count(c)) {
|
||||
switch(pos.piece_count(c, BISHOP)) {
|
||||
case 2:
|
||||
mi->factor[c] = 32; break;
|
||||
case 1:
|
||||
|
@ -378,7 +378,7 @@ MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
|
|||
}
|
||||
|
||||
// Bishop pair:
|
||||
if(pos.bishop_count(c) >= 2) {
|
||||
if(pos.piece_count(c, BISHOP) >= 2) {
|
||||
mgValue += sign * BishopPairMidgameBonus;
|
||||
egValue += sign * BishopPairEndgameBonus;
|
||||
}
|
||||
|
@ -387,12 +387,12 @@ MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
|
|||
// formula is taken from Larry Kaufman's paper "The Evaluation of Material
|
||||
// Imbalances in Chess":
|
||||
// http://mywebpages.comcast.net/danheisman/Articles/evaluation_of_material_imbalance.htm
|
||||
mgValue += sign * Value(pos.knight_count(c)*(pos.pawn_count(c)-5)*16);
|
||||
egValue += sign * Value(pos.knight_count(c)*(pos.pawn_count(c)-5)*16);
|
||||
mgValue += sign * Value(pos.piece_count(c, KNIGHT)*(pos.piece_count(c, PAWN)-5)*16);
|
||||
egValue += sign * Value(pos.piece_count(c, KNIGHT)*(pos.piece_count(c, PAWN)-5)*16);
|
||||
|
||||
// Redundancy of major pieces, again based on Kaufman's paper:
|
||||
if(pos.rook_count(c) >= 1) {
|
||||
Value v = Value((pos.rook_count(c) - 1) * 32 + pos.queen_count(c) * 16);
|
||||
if(pos.piece_count(c, ROOK) >= 1) {
|
||||
Value v = Value((pos.piece_count(c, ROOK) - 1) * 32 + pos.piece_count(c, QUEEN) * 16);
|
||||
mgValue -= sign * v;
|
||||
egValue -= sign * v;
|
||||
}
|
||||
|
|
|
@ -171,11 +171,6 @@ public:
|
|||
|
||||
// Number of pieces of each color and type
|
||||
int piece_count(Color c, PieceType pt) const;
|
||||
int pawn_count(Color c) const;
|
||||
int knight_count(Color c) const;
|
||||
int bishop_count(Color c) const;
|
||||
int rook_count(Color c) const;
|
||||
int queen_count(Color c) const;
|
||||
|
||||
// The en passant square:
|
||||
Square ep_square() const;
|
||||
|
@ -491,26 +486,6 @@ inline int Position::piece_count(Color c, PieceType pt) const {
|
|||
return pieceCount[c][pt];
|
||||
}
|
||||
|
||||
inline int Position::pawn_count(Color c) const {
|
||||
return piece_count(c, PAWN);
|
||||
}
|
||||
|
||||
inline int Position::knight_count(Color c) const {
|
||||
return piece_count(c, KNIGHT);
|
||||
}
|
||||
|
||||
inline int Position::bishop_count(Color c) const {
|
||||
return piece_count(c, BISHOP);
|
||||
}
|
||||
|
||||
inline int Position::rook_count(Color c) const {
|
||||
return piece_count(c, ROOK);
|
||||
}
|
||||
|
||||
inline int Position::queen_count(Color c) const {
|
||||
return piece_count(c, QUEEN);
|
||||
}
|
||||
|
||||
inline Square Position::piece_list(Color c, PieceType pt, int index) const {
|
||||
return pieceList[c][pt][index];
|
||||
}
|
||||
|
@ -707,8 +682,8 @@ inline int Position::rule_50_counter() const {
|
|||
|
||||
inline bool Position::opposite_colored_bishops() const {
|
||||
|
||||
return bishop_count(WHITE) == 1
|
||||
&& bishop_count(BLACK) == 1
|
||||
return piece_count(WHITE, BISHOP) == 1
|
||||
&& piece_count(BLACK, BISHOP) == 1
|
||||
&& square_color(piece_list(WHITE, BISHOP, 0)) != square_color(piece_list(BLACK, BISHOP, 0));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue