X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmaterial.h;h=89f8f55685d0979b1cf6f07d748e897ee9df6c08;hp=c5484c49032395da2e20f248c4a0ab3549d78c72;hb=e304db9d1ecf6a2318708483c90fadecf4fac4ee;hpb=304deb5e833baf47c147e93377f5c7ef582ab822 diff --git a/src/material.h b/src/material.h index c5484c49..89f8f556 100644 --- a/src/material.h +++ b/src/material.h @@ -21,19 +21,12 @@ #define MATERIAL_H_INCLUDED #include "endgame.h" +#include "misc.h" #include "position.h" -#include "tt.h" #include "types.h" const int MaterialTableSize = 8192; -/// Game phase -enum Phase { - PHASE_ENDGAME = 0, - PHASE_MIDGAME = 128 -}; - - /// MaterialEntry is a class which contains various information about a /// material configuration. It contains a material balance evaluation, /// a function pointer to a special endgame evaluation function (which in @@ -46,7 +39,7 @@ enum Phase { class MaterialEntry { - friend class MaterialTable; + friend struct MaterialTable; public: Score material_value() const; @@ -59,9 +52,9 @@ public: private: Key key; int16_t value; - uint8_t factor[2]; + uint8_t factor[COLOR_NB]; EndgameBase* evaluationFunction; - EndgameBase* scalingFunction[2]; + EndgameBase* scalingFunction[COLOR_NB]; int spaceWeight; Phase gamePhase; }; @@ -70,19 +63,14 @@ private: /// The MaterialTable class represents a material hash table. The most important /// method is probe(), which returns a pointer to a MaterialEntry object. -class MaterialTable : public HashTable { -public: - MaterialTable() : funcs(new Endgames()) {} - ~MaterialTable() { delete funcs; } +struct MaterialTable { - MaterialEntry* probe(const Position& pos) const; + MaterialEntry* probe(const Position& pos); static Phase game_phase(const Position& pos); + template static int imbalance(const int pieceCount[][PIECE_TYPE_NB]); -private: - template - static int imbalance(const int pieceCount[][8]); - - Endgames* funcs; + HashTable entries; + Endgames endgames; };