説明を見る。00001
00002
00003 #ifndef OSL_EVAL_ML_PIECEPAIRKING_H
00004 #define OSL_EVAL_ML_PIECEPAIRKING_H
00005
00006 #include "osl/numEffectState.h"
00007 namespace osl
00008 {
00009 namespace eval
00010 {
00011 namespace ml
00012 {
00013 struct Weights;
00014 class PiecePairKing
00015 {
00016 public:
00017 enum
00018 {
00019 ONE_DIM = 1488375,
00020 DIM = ONE_DIM
00021 };
00022 static void setUp(const Weights &weights);
00023 static CArray<int,2> eval(const NumEffectState&);
00024 template <Player P>
00025 static void evalWithUpdateBang(const NumEffectState& state, Move moved, CArray<int,2>& last_value);
00026
00027 template <Player King>
00028 static int evalOne(const NumEffectState&);
00029 private:
00030 template <Player King>
00031 static int add(const NumEffectState& state, Square to, Ptype ptype);
00032 template <Player King>
00033 static int sub(const NumEffectState& state, Square from, Ptype ptype);
00034 template <Player King>
00035 static int addSub(const NumEffectState& state, Square to, Ptype ptype, Square from);
00036 static int composeIndex(int king, int i0, int i1)
00037 {
00038 return king + i0*45*7 + i1;
00039 }
00040 static int indexWhite(Square p)
00041 {
00042 return p.x()-1 + (p.y()-1)*9;
00043 }
00044 static int indexKing(Player owner, Square king, bool& flipx)
00045 {
00046 if (owner == BLACK)
00047 king = king.rotate180();
00048 assert(king.y() <= 3);
00049 if (king.x() > 5)
00050 {
00051 king = king.flipHorizontal();
00052 flipx = true;
00053 }
00054 else
00055 flipx = false;
00056 return (king.x()-1 + (king.y()-1)*5)*45*7*45*7;
00057 }
00058 template <bool FlipX>
00059 static int indexPiece(Player owner, Square position, Ptype ptype)
00060 {
00061 assert(! isPromoted(ptype));
00062 if (owner == BLACK)
00063 position = position.rotate180();
00064 if (FlipX)
00065 position = position.flipHorizontal();
00066 assert(position.y() <= 5);
00067 return indexWhite(position)*7 + ptype-PTYPE_BASIC_MIN-1;
00068 }
00069 static osl::CArray<int16_t, ONE_DIM> table;
00070 };
00071 }
00072 }
00073 }
00074
00075
00076 #endif
00077
00078
00079
00080