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