Go to the documentation of this file.00001
00002
00003
00004 #ifndef EVAL_ML_PIN_H
00005 #define EVAL_ML_PIN_H
00006
00007 #include "osl/ptype.h"
00008 #include "osl/misc/carray.h"
00009 #include "osl/state/numEffectState.h"
00010 #include "osl/eval/ml/weights.h"
00011 #include "osl/eval/ml/midgame.h"
00012
00013 namespace osl
00014 {
00015 namespace eval
00016 {
00017 namespace ml
00018 {
00019 class SimplePin
00020 {
00021 static CArray<int, PTYPE_SIZE> table;
00022 public:
00023 SimplePin() { };
00024 static void setUp(const Weights &weights);
00025 int eval(const NumEffectState &state,
00026 PieceMask black_mask, PieceMask white_mask) const;
00027 };
00028
00029 class Pin
00030 {
00031 static int index(const Square king,
00032 const Piece piece)
00033 {
00034 return std::abs(piece.square().x() - king.x()) * 17 +
00035 (piece.owner() == BLACK ? (king.y() - piece.square().y()) :
00036 (piece.square().y() - king.y())) + 8;
00037 }
00038 static CArray2d<MultiInt, PTYPE_SIZE, 17 * 9> table;
00039 public:
00040 enum { DIM = (osl::PTYPE_MAX - osl::PTYPE_PIECE_MIN + 1) * 17 * 9};
00041 Pin() { };
00042 static void setUp(const Weights &weights,int stage);
00043 static MultiInt eval(const NumEffectState &state,
00044 PieceMask black_mask, PieceMask white_mask);
00045 };
00046
00047 class PinPtypeAll
00048 {
00049 public:
00050 static MultiInt eval(const NumEffectState &state);
00051 private:
00052 template <Player Defense>
00053 static MultiInt evalOne(const NumEffectState &state);
00054 template <Player Defense>
00055 static bool pawnAttack(const NumEffectState &state, Piece piece)
00056 {
00057 const Square up =
00058 piece.square() + DirectionPlayerTraits<U, Defense>::offset();
00059 return (up.isOnBoard() &&
00060 (state.hasEffectByPtypeStrict<PAWN>(alt(Defense), up)
00061 || (!state.isPawnMaskSet(alt(Defense),
00062 piece.square().x())
00063 && state.pieceAt(up).isEmpty())));
00064 }
00065 protected:
00066 static CArray<MultiInt, 80> table;
00067 static CArray<MultiInt, 48> pawn_table;
00068 static CArray<MultiInt, 560> distance_table;
00069 };
00070
00071 class PinPtype : public PinPtypeAll
00072 {
00073 public:
00074 enum { ONE_DIM = 80, DIM = ONE_DIM * EvalStages };
00075 static void setUp(const Weights &weights);
00076 };
00077
00078 class PinPtypeDistance : public PinPtypeAll
00079 {
00080 public:
00081 enum { ONE_DIM = 560, DIM = ONE_DIM * EvalStages };
00082 static void setUp(const Weights &weights);
00083 };
00084
00085 class PinPtypePawnAttack : public PinPtypeAll
00086 {
00087 public:
00088 enum { ONE_DIM = 48, DIM = ONE_DIM * EvalStages };
00089 static void setUp(const Weights &weights);
00090 };
00091
00092 class CheckShadowPtype
00093 {
00094 public:
00095 enum {
00096
00097 ONE_DIM = PTYPE_SIZE * 5,
00098 DIM = ONE_DIM * EvalStages
00099 };
00100 static void setUp(const Weights &weights);
00101 static MultiInt eval(const NumEffectState &state);
00102 template <Player King>
00103 static MultiInt evalOne(const NumEffectState &state);
00104 static CArray<MultiInt, ONE_DIM> table;
00105 };
00106 }
00107 }
00108 }
00109 #endif // EVAL_ML_PIN_H
00110
00111
00112
00113