@@ -212,19 +212,19 @@ KPKPScalingFunction::KPKPScalingFunction(Color c) : ScalingFunction(c) { }
Value KXKEvaluationFunction::apply(const Position &pos) {

assert(pos.non_pawn_material(weakerSide) == Value(0));
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) +

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));

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;

// TODO: check for two equal-colored bishops!
result += VALUE_KNOWN_WIN;

@@ -238,16 +238,16 @@ Value KXKEvaluationFunction::apply(const Position &pos) {
Value KBNKEvaluationFunction::apply(const Position &pos) {

assert(pos.non_pawn_material(weakerSide) == Value(0));
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.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);

Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide);
-  Square bishopSquare = pos.bishop_list(strongerSide, 0);
+  Square bishopSquare = pos.piece_list(strongerSide, BISHOP, 0);

if(square_color(bishopSquare) == BLACK) {
winnerKSq = flop_square(winnerKSq);

if(square_color(bishopSquare) == BLACK) {
winnerKSq = flop_square(winnerKSq);
@@ -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.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;

Square wksq, bksq, wpsq;
Color stm;
@@ -277,13 +277,13 @@ Value KPKEvaluationFunction::apply(const Position &pos) {
if(strongerSide == WHITE) {
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
if(strongerSide == WHITE) {
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
-    wpsq = pos.pawn_list(WHITE, 0);
+    wpsq = pos.piece_list(WHITE, PAWN, 0);
stm = pos.side_to_move();
}
else {
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
stm = pos.side_to_move();
}
else {
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
-    wpsq = flip_square(pos.pawn_list(BLACK, 0));
+    wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
stm = opposite_color(pos.side_to_move());
}

stm = opposite_color(pos.side_to_move());
}

@@ -311,17 +311,17 @@ Value KPKEvaluationFunction::apply(const Position &pos) {
Value KRKPEvaluationFunction::apply(const Position &pos) {

assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
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.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);

wksq = pos.king_square(strongerSide);

Square wksq, wrsq, bksq, bpsq;
int tempo = (pos.side_to_move() == strongerSide);

wksq = pos.king_square(strongerSide);
-  wrsq = pos.rook_list(strongerSide, 0);
+  wrsq = pos.piece_list(strongerSide, ROOK, 0);
bksq = pos.king_square(weakerSide);
bksq = pos.king_square(weakerSide);
-  bpsq = pos.pawn_list(weakerSide, 0);
+  bpsq = pos.piece_list(weakerSide, PAWN, 0);

if(strongerSide == BLACK) {
wksq = flip_square(wksq);

if(strongerSide == BLACK) {
wksq = flip_square(wksq);
@@ -366,10 +366,10 @@ Value KRKPEvaluationFunction::apply(const Position &pos) {
Value KRKBEvaluationFunction::apply(const Position &pos) {

assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
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.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;

Value result = mate_table(pos.king_square(weakerSide));
return (pos.side_to_move() == strongerSide)? result : -result;
@@ -382,13 +382,13 @@ Value KRKBEvaluationFunction::apply(const Position &pos) {
Value KRKNEvaluationFunction::apply(const Position &pos) {

assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
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.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 defendingKSq = pos.king_square(weakerSide);
-  Square nSq = pos.knight_list(weakerSide, 0);
+  Square nSq = pos.piece_list(weakerSide, KNIGHT, 0);

Value result = Value(10) + mate_table(defendingKSq) +
krkn_king_knight_distance_penalty(square_distance(defendingKSq, nSq));

Value result = Value(10) + mate_table(defendingKSq) +
krkn_king_knight_distance_penalty(square_distance(defendingKSq, nSq));
@@ -405,9 +405,9 @@ Value KRKNEvaluationFunction::apply(const Position &pos) {

Value KQKREvaluationFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);

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.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);

Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide);
@@ -427,20 +427,20 @@ Value KQKREvaluationFunction::apply(const Position &pos) {

ScaleFactor KBPKScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);

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.

Bitboard pawns = pos.pawns(strongerSide);

// No assertions about the material of weakerSide, because we want draws to
// be detected even when the weaker side has some pawns.

Bitboard pawns = pos.pawns(strongerSide);
-  File pawnFile = square_file(pos.pawn_list(strongerSide, 0));
+  File pawnFile = square_file(pos.piece_list(strongerSide, PAWN, 0));

if((pawnFile == FILE_A || pawnFile == FILE_H) &&
(pawns & ~file_bb(pawnFile)) == EmptyBoardBB) {
// All pawns are on a single rook file.

if((pawnFile == FILE_A || pawnFile == FILE_H) &&
(pawns & ~file_bb(pawnFile)) == EmptyBoardBB) {
// All pawns are on a single rook file.

-    Square bishopSq = pos.bishop_list(strongerSide, 0);
+    Square bishopSq = pos.piece_list(strongerSide, BISHOP, 0);
Square queeningSq =
relative_square(strongerSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakerSide);
Square queeningSq =
relative_square(strongerSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakerSide);
@@ -479,18 +479,18 @@ ScaleFactor KBPKScalingFunction::apply(const Position &pos) {

ScaleFactor KQKRPScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);

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 &&
relative_rank(weakerSide, pos.king_square(strongerSide)) >= RANK_4 &&
(pos.rooks(weakerSide) & relative_rank_bb(weakerSide, RANK_3)) &&
(pos.pawns(weakerSide) & relative_rank_bb(weakerSide, RANK_2)) &&

Square kingSq = pos.king_square(weakerSide);
if(relative_rank(weakerSide, kingSq) <= RANK_2 &&
relative_rank(weakerSide, pos.king_square(strongerSide)) >= RANK_4 &&
(pos.rooks(weakerSide) & relative_rank_bb(weakerSide, RANK_3)) &&
(pos.pawns(weakerSide) & relative_rank_bb(weakerSide, RANK_2)) &&
-     (pos.king_attacks(kingSq) & pos.pawns(weakerSide))) {
-    Square rsq = pos.rook_list(weakerSide, 0);
+     (pos.piece_attacks<KING>(kingSq) & pos.pawns(weakerSide))) {
+    Square rsq = pos.piece_list(weakerSide, ROOK, 0);
if(pos.pawn_attacks(strongerSide, rsq) & pos.pawns(weakerSide))
return ScaleFactor(0);
}
if(pos.pawn_attacks(strongerSide, rsq) & pos.pawns(weakerSide))
return ScaleFactor(0);
}
@@ -508,15 +508,15 @@ ScaleFactor KQKRPScalingFunction::apply(const Position &pos) {

ScaleFactor KRPKRScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);

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.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 wksq = pos.king_square(strongerSide);
-  Square wrsq = pos.rook_list(strongerSide, 0);
-  Square wpsq = pos.pawn_list(strongerSide, 0);
+  Square wrsq = pos.piece_list(strongerSide, ROOK, 0);
+  Square wpsq = pos.piece_list(strongerSide, PAWN, 0);
Square bksq = pos.king_square(weakerSide);
Square bksq = pos.king_square(weakerSide);
-  Square brsq = pos.rook_list(weakerSide, 0);
+  Square brsq = pos.piece_list(weakerSide, ROOK, 0);

// Orient the board in such a way that the stronger side is white, and the
// pawn is on the left half of the board:

// Orient the board in such a way that the stronger side is white, and the
// pawn is on the left half of the board:
@@ -613,12 +613,12 @@ ScaleFactor KRPKRScalingFunction::apply(const Position &pos) {

ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);

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.non_pawn_material(weakerSide) == RookValueMidgame);
-  assert(pos.pawn_count(weakerSide) == 1);
+  assert(pos.piece_count(weakerSide, PAWN) == 1);

-  Square wpsq1 = pos.pawn_list(strongerSide, 0);
-  Square wpsq2 = pos.pawn_list(strongerSide, 1);
+  Square wpsq1 = pos.piece_list(strongerSide, PAWN, 0);
+  Square wpsq2 = pos.piece_list(strongerSide, PAWN, 1);
Square bksq = pos.king_square(weakerSide);

// Does the stronger side have a passed pawn?
Square bksq = pos.king_square(weakerSide);

// Does the stronger side have a passed pawn?
@@ -651,9 +651,9 @@ ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) {

ScaleFactor KPsKScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == Value(0));

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.non_pawn_material(weakerSide) == Value(0));
-  assert(pos.pawn_count(weakerSide) == 0);
+  assert(pos.piece_count(weakerSide, PAWN) == 0);

Bitboard pawns = pos.pawns(strongerSide);

Bitboard pawns = pos.pawns(strongerSide);

@@ -694,15 +694,15 @@ ScaleFactor KPsKScalingFunction::apply(const Position &pos) {

ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);

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.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.pawn_list(strongerSide, 0);
-  Square strongerBishopSq = pos.bishop_list(strongerSide, 0);
-  Square weakerBishopSq = pos.bishop_list(weakerSide, 0);
+  Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
+  Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
+  Square weakerBishopSq = pos.piece_list(weakerSide, BISHOP, 0);
Square weakerKingSq = pos.king_square(weakerSide);

// Case 1: Defending king blocks the pawn, and cannot be driven away.
Square weakerKingSq = pos.king_square(weakerSide);

// Case 1: Defending king blocks the pawn, and cannot be driven away.
@@ -732,7 +732,7 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
ray_bb(pawnSq, (strongerSide == WHITE)? SIGNED_DIR_N : SIGNED_DIR_S);
if(ray & pos.kings(weakerSide))
return ScaleFactor(0);
ray_bb(pawnSq, (strongerSide == WHITE)? SIGNED_DIR_N : SIGNED_DIR_S);
if(ray & pos.kings(weakerSide))
return ScaleFactor(0);
-      if((pos.bishop_attacks(weakerBishopSq) & ray)
+      if((pos.piece_attacks<BISHOP>(weakerBishopSq) & ray)
&& square_distance(weakerBishopSq, pawnSq) >= 3)
return ScaleFactor(0);
}
&& square_distance(weakerBishopSq, pawnSq) >= 3)
return ScaleFactor(0);
}
@@ -748,14 +748,14 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {

ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);

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.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.pawn_list(strongerSide, 0);
-  Square strongerBishopSq = pos.bishop_list(strongerSide, 0);
+  Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
+  Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
Square weakerKingSq = pos.king_square(weakerSide);

if(square_file(weakerKingSq) == square_file(pawnSq)
Square weakerKingSq = pos.king_square(weakerSide);

if(square_file(weakerKingSq) == square_file(pawnSq)
@@ -774,12 +774,12 @@ ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {

ScaleFactor KNPKScalingFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame);

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.non_pawn_material(weakerSide) == Value(0));
-  assert(pos.pawn_count(weakerSide) == 0);
+  assert(pos.piece_count(weakerSide, PAWN) == 0);

-  Square pawnSq = pos.pawn_list(strongerSide, 0);
+  Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
Square weakerKingSq = pos.king_square(weakerSide);

if(pawnSq == relative_square(strongerSide, SQ_A7) &&
Square weakerKingSq = pos.king_square(weakerSide);

if(pawnSq == relative_square(strongerSide, SQ_A7) &&
@@ -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));
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;

Square wksq, bksq, wpsq;
Color stm;
@@ -813,13 +813,13 @@ ScaleFactor KPKPScalingFunction::apply(const Position &pos) {
if(strongerSide == WHITE) {
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
if(strongerSide == WHITE) {
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
-    wpsq = pos.pawn_list(WHITE, 0);
+    wpsq = pos.piece_list(WHITE, PAWN, 0);
stm = pos.side_to_move();
}
else {
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
stm = pos.side_to_move();
}
else {
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
-    wpsq = flip_square(pos.pawn_list(BLACK, 0));
+    wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
stm = opposite_color(pos.side_to_move());
}

stm = opposite_color(pos.side_to_move());
}