X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=73a4463362a6e2fb4e63cc1c676cab66aa779ab0;hp=3e572205970d63cba9da91421e81bd291cf5e36c;hb=5a7b45eac9dedbf7ebc61d9deb4dd934058d1ca1;hpb=badb2aca44d6507f35dafc8b5c3921a6649a40f8
diff --git a/src/endgame.cpp b/src/endgame.cpp
index 3e572205..73a44633 100644
--- a/src/endgame.cpp
+++ b/src/endgame.cpp
@@ -2,7 +2,7 @@
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
- Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
+ Copyright (C) 2015-2020 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
along with this program. If not, see .
*/
-#include
#include
#include "bitboard.h"
@@ -55,9 +54,9 @@ namespace {
4160, 4480, 4800, 5120, 5440, 5760, 6080, 6400
};
- // Tables used to drive a piece towards or away from another piece
- constexpr int PushClose[8] = { 0, 0, 100, 80, 60, 40, 20, 10 };
- constexpr int PushAway [8] = { 0, 5, 20, 40, 60, 80, 90, 100 };
+ // Drive a piece close to or away from another piece
+ inline int push_close(Square s1, Square s2) { return 140 - 20 * distance(s1, s2); }
+ inline int push_away(Square s1, Square s2) { return 120 - push_close(s1, s2); }
// Pawn Rank based scaling factors used in KRPPKRP endgame
constexpr int KRPPKRPScaleFactors[RANK_NB] = { 0, 9, 10, 14, 21, 44, 0, 0 };
@@ -75,17 +74,42 @@ namespace {
assert(pos.count(strongSide) == 1);
if (file_of(pos.square(strongSide)) >= FILE_E)
- sq = Square(sq ^ 7); // Mirror SQ_H1 -> SQ_A1
+ sq = flip_file(sq);
- if (strongSide == BLACK)
- sq = ~sq;
-
- return sq;
+ return strongSide == WHITE ? sq : flip_rank(sq);
}
} // namespace
+namespace Endgames {
+
+ std::pair