]> git.sesse.net Git - stockfish/blobdiff - src/endgame.cpp
Retire piece.cpp
[stockfish] / src / endgame.cpp
index 24c8c5d41c344dd3cd501d6e955024eb7988ff17..bb756f3b20cd558922c4fc6c416b055e962c3b6d 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <cassert>
 
-#include "bitbase.h"
 #include "bitcount.h"
 #include "endgame.h"
 
@@ -102,6 +101,7 @@ namespace {
 /// init_bitbases() is called during program initialization, and simply loads
 /// bitbases from disk into memory.  At the moment, there is only the bitbase
 /// for KP vs K, but we may decide to add other bitbases later.
+extern void generate_kpk_bitbase(uint8_t bitbase[]);
 
 void init_bitbases() {
   generate_kpk_bitbase(KPKBitbase);
@@ -115,8 +115,8 @@ void init_bitbases() {
 template<>
 Value EvaluationFunction<KXK>::apply(const Position& pos) const {
 
-  assert(pos.non_pawn_material(weakerSide) == Value(0));
-  assert(pos.piece_count(weakerSide, PAWN) == Value(0));
+  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
+  assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO);
 
   Square winnerKSq = pos.king_square(strongerSide);
   Square loserKSq = pos.king_square(weakerSide);
@@ -141,8 +141,8 @@ Value EvaluationFunction<KXK>::apply(const Position& pos) const {
 template<>
 Value EvaluationFunction<KBNK>::apply(const Position& pos) const {
 
-  assert(pos.non_pawn_material(weakerSide) == Value(0));
-  assert(pos.piece_count(weakerSide, PAWN) == Value(0));
+  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
+  assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO);
   assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame + BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
   assert(pos.piece_count(strongerSide, KNIGHT) == 1);
@@ -173,8 +173,8 @@ Value EvaluationFunction<KBNK>::apply(const Position& pos) const {
 template<>
 Value EvaluationFunction<KPK>::apply(const Position& pos) const {
 
-  assert(pos.non_pawn_material(strongerSide) == Value(0));
-  assert(pos.non_pawn_material(weakerSide) == Value(0));
+  assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO);
+  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
   assert(pos.piece_count(strongerSide, PAWN) == 1);
   assert(pos.piece_count(weakerSide, PAWN) == 0);
 
@@ -357,7 +357,7 @@ Value EvaluationFunction<KBBKN>::apply(const Position& pos) const {
   result += Value(square_distance(bksq, nsq) * 32);
 
   // Bonus for restricting the knight's mobility
-  result += Value((8 - count_1s_max_15(pos.attacks_from<KNIGHT>(nsq))) * 8);
+  result += Value((8 - count_1s<CNT32_MAX15>(pos.attacks_from<KNIGHT>(nsq))) * 8);
 
   return strongerSide == pos.side_to_move() ? result : -result;
 }
@@ -367,12 +367,12 @@ Value EvaluationFunction<KBBKN>::apply(const Position& pos) const {
 /// king alone are always draw.
 template<>
 Value EvaluationFunction<KmmKm>::apply(const Position&) const {
-  return Value(0);
+  return VALUE_DRAW;
 }
 
 template<>
 Value EvaluationFunction<KNNK>::apply(const Position&) const {
-  return Value(0);
+  return VALUE_DRAW;
 }
 
 /// KBPKScalingFunction scales endgames where the stronger side has king,
@@ -625,9 +625,9 @@ ScaleFactor ScalingFunction<KRPPKRP>::apply(const Position& pos) const {
 template<>
 ScaleFactor ScalingFunction<KPsK>::apply(const Position& pos) const {
 
-  assert(pos.non_pawn_material(strongerSide) == Value(0));
+  assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO);
   assert(pos.piece_count(strongerSide, PAWN) >= 2);
-  assert(pos.non_pawn_material(weakerSide) == Value(0));
+  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
   assert(pos.piece_count(weakerSide, PAWN) == 0);
 
   Square ksq = pos.king_square(weakerSide);
@@ -824,7 +824,7 @@ ScaleFactor ScalingFunction<KNPK>::apply(const Position& pos) const {
   assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame);
   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_ZERO);
   assert(pos.piece_count(weakerSide, PAWN) == 0);
 
   Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
@@ -851,8 +851,8 @@ ScaleFactor ScalingFunction<KNPK>::apply(const Position& pos) const {
 template<>
 ScaleFactor ScalingFunction<KPKP>::apply(const Position& pos) const {
 
-  assert(pos.non_pawn_material(strongerSide) == Value(0));
-  assert(pos.non_pawn_material(weakerSide) == Value(0));
+  assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO);
+  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
   assert(pos.piece_count(WHITE, PAWN) == 1);
   assert(pos.piece_count(BLACK, PAWN) == 1);