#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
class MaterialEntry {
- friend class MaterialTable;
+ friend struct MaterialTable;
public:
Score material_value() const;
private:
Key key;
int16_t value;
- uint8_t factor[2];
+ uint8_t factor[COLOR_NB];
EndgameBase<Value>* evaluationFunction;
- EndgameBase<ScaleFactor>* scalingFunction[2];
+ EndgameBase<ScaleFactor>* scalingFunction[COLOR_NB];
int spaceWeight;
Phase gamePhase;
};
/// 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<MaterialEntry, MaterialTableSize> {
-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<Color Us> static int imbalance(const int pieceCount[][PIECE_TYPE_NB]);
-private:
- template<Color Us>
- static int imbalance(const int pieceCount[][8]);
-
- Endgames* funcs;
+ HashTable<MaterialEntry, MaterialTableSize> entries;
+ Endgames endgames;
};