mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 02:27:00 +08:00
Simplify endgame functions handling
We really don't need to have global endgame functions. We can allocate them on the heap at initialization time and store the corresponding pointer directly in the functions maps. To avoid leaks we just need to remember to deallocate them in map d'tor. These functions are always created in couple, one for each color, so remove a lot of redundant hard coded info and just use the minimum required: the type and the corresponding named string. This greatly simplifies the code and also it is less error prone, now is much simpler to add a new endgame specialized function: just add the corresponding enum in endgame.h and the obvious add_xx() call in EndgameFunctions c'tor, and of course, the most important part, the EvaluationFunction<xxx>::apply() specialization in endgame.cpp No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -92,31 +92,6 @@ struct ScalingFunction : public EndgameScalingFunctionBase {
|
||||
};
|
||||
|
||||
|
||||
////
|
||||
//// Constants and variables
|
||||
////
|
||||
|
||||
extern EvaluationFunction<KXK> EvaluateKXK, EvaluateKKX; // Generic "mate lone king" eval
|
||||
extern EvaluationFunction<KBNK> EvaluateKBNK, EvaluateKKBN; // KBN vs K
|
||||
extern EvaluationFunction<KPK> EvaluateKPK, EvaluateKKP; // KP vs K
|
||||
extern EvaluationFunction<KRKP> EvaluateKRKP, EvaluateKPKR; // KR vs KP
|
||||
extern EvaluationFunction<KRKB> EvaluateKRKB, EvaluateKBKR; // KR vs KB
|
||||
extern EvaluationFunction<KRKN> EvaluateKRKN, EvaluateKNKR; // KR vs KN
|
||||
extern EvaluationFunction<KQKR> EvaluateKQKR, EvaluateKRKQ; // KQ vs KR
|
||||
extern EvaluationFunction<KBBKN> EvaluateKBBKN, EvaluateKNKBB; // KBB vs KN
|
||||
extern EvaluationFunction<KmmKm> EvaluateKmmKm; // K and two minors vs K and one or two minors:
|
||||
|
||||
extern ScalingFunction<KBPK> ScaleKBPK, ScaleKKBP; // KBP vs K
|
||||
extern ScalingFunction<KQKRP> ScaleKQKRP, ScaleKRPKQ; // KQ vs KRP
|
||||
extern ScalingFunction<KRPKR> ScaleKRPKR, ScaleKRKRP; // KRP vs KR
|
||||
extern ScalingFunction<KRPPKRP> ScaleKRPPKRP, ScaleKRPKRPP; // KRPP vs KRP
|
||||
extern ScalingFunction<KPsK> ScaleKPsK, ScaleKKPs; // King and pawns vs king
|
||||
extern ScalingFunction<KBPKB> ScaleKBPKB, ScaleKBKBP; // KBP vs KB
|
||||
extern ScalingFunction<KBPPKB> ScaleKBPPKB, ScaleKBKBPP; // KBPP vs KB
|
||||
extern ScalingFunction<KBPKN> ScaleKBPKN, ScaleKNKBP; // KBP vs KN
|
||||
extern ScalingFunction<KNPK> ScaleKNPK, ScaleKKNP; // KNP vs K
|
||||
extern ScalingFunction<KPKP> ScaleKPKPw, ScaleKPKPb; // KP vs KP
|
||||
|
||||
////
|
||||
//// Prototypes
|
||||
////
|
||||
|
||||
Reference in New Issue
Block a user