説明を見る。00001
00002
00003
00004 #ifndef EVAL_ML_MOBILITY_H
00005 #define EVAL_ML_MOBILITY_H
00006
00007 #include "osl/eval/weights.h"
00008 #include "osl/eval/midgame.h"
00009 #include "osl/numEffectState.h"
00010
00011 namespace osl
00012 {
00013 namespace eval
00014 {
00015 namespace ml
00016 {
00017 class RookMobilityAll
00018 {
00019 friend class RookMobility;
00020 friend class RookMobilityX;
00021 friend class RookMobilityY;
00022 friend class RookMobilitySum;
00023 friend class RookMobilitySumKingX;
00024 friend class RookMobilityXKingX;
00025 public:
00026 template<int Sign>
00027 static void adjust(const NumEffectState&, bool promoted,
00028 int vertical, int horizontal,
00029 Square pos,
00030 MultiInt& value);
00031 static void eval(const NumEffectState&, MultiInt& out);
00032 private:
00033 static int indexX(Square rook, bool promoted,
00034 int count, bool vertical)
00035 {
00036 const int x = (rook.x() > 5 ?
00037 10 - rook.x() : rook.x());
00038 return x - 1 + 5 * ((promoted ? 1 : 0) +
00039 2 * ((vertical ? 1 : 0) + 2 * count));
00040 }
00041 template <int Sign>
00042 static int indexY(Square rook, bool promoted,
00043 int count, bool vertical)
00044 {
00045 const int y = (Sign > 0 ? rook.y() : 10 - rook.y());
00046 return y - 1 + 9 * ((promoted ? 1 : 0) +
00047 2 * ((vertical ? 1 : 0) + 2 * count));
00048 }
00049 template <int Sign>
00050 static int indexXKingX(Square rook, Square king, int count, bool vertical)
00051 {
00052 const Square r = (Sign > 0) ? rook : rook.rotate180();
00053 const Square k = (Sign > 0) ? king : king.rotate180();
00054 const bool flip = r.x() > 5;
00055 const int x = (flip ? 10 - r.x() : r.x());
00056 const int king_x = (flip ? 10 - k.x() : k.x());
00057 return king_x - 1 + 9 * (x - 1 + 5 * ((vertical ? 1 : 0) + 2 * count));
00058 }
00059 static CArray<MultiInt, 18> rook_vertical_table;
00060 static CArray<MultiInt, 18> rook_horizontal_table;
00061 static CArray<MultiInt, 34> sum_table;
00062 static CArray<MultiInt, 324> x_table;
00063 static CArray<MultiInt, 324> y_table;
00064 static CArray<MultiInt, 17 * 9> sumkingx_table;
00065 static CArray<MultiInt, 9 * 2 * 5 * 9> xkingx_table;
00066 };
00067
00068 class RookMobility
00069 {
00070 public:
00071 enum { DIM = 36 };
00072 static void setUp(const Weights &weights,int stage);
00073 };
00074
00075 class RookMobilitySum
00076 {
00077 public:
00078 enum { ONE_DIM = 34, DIM = ONE_DIM * EvalStages };
00079 static void setUp(const Weights &weights);
00080 };
00081 class RookMobilityX
00082 {
00083 public:
00084 enum { ONE_DIM = 180, DIM = ONE_DIM * EvalStages };
00085 static void setUp(const Weights &weights);
00086 };
00087 class RookMobilityY
00088 {
00089 public:
00090 enum { ONE_DIM = 324, DIM = ONE_DIM * EvalStages };
00091 static void setUp(const Weights &weights);
00092 };
00093 class RookMobilitySumKingX
00094 {
00095 public:
00096 enum { ONE_DIM = 17 * 9, DIM = ONE_DIM * EvalStages };
00097 static void setUp(const Weights &weights);
00098 };
00099 class RookMobilityXKingX
00100 {
00101 public:
00102 enum { ONE_DIM = 9 * 2 * 5 * 9, DIM = ONE_DIM * EvalStages };
00103 static void setUp(const Weights &weights);
00104 };
00105
00106 struct BishopMobilityAll
00107 {
00108 friend class BishopMobility;
00109 friend class BishopMobilityEach;
00110 public:
00111 template<int Sign>
00112 static void adjust(bool promoted, int mobility1, int mobility2,
00113 MultiInt& value);
00114 static void eval(const NumEffectState&, MultiInt& out);
00115 private:
00116 static CArray<MultiInt, 36> bishop_table;
00117 static CArray<MultiInt, 18> each_table;
00118 };
00119 class BishopMobility
00120 {
00121 public:
00122 enum { DIM = 36 };
00123 static void setUp(const Weights &weights,int stage);
00124 };
00125 class BishopMobilityEach
00126 {
00127 public:
00128 enum { ONE_DIM = 18, DIM = ONE_DIM * EvalStages };
00129 static void setUp(const Weights &weights);
00130 };
00131 struct LanceMobilityAll
00132 {
00133 template<int Sign>
00134 static void adjust(int index, MultiInt& value);
00135 static void eval(const NumEffectState&, MultiInt& out);
00136 };
00137 class LanceMobility
00138 {
00139 static CArray<MultiInt, 9> lance_table;
00140 friend struct LanceMobilityAll;
00141 public:
00142 enum { DIM = 9 };
00143 LanceMobility() { };
00144 static void setUp(const Weights &weights,int stage);
00145 };
00146 }
00147 }
00148 }
00149 #endif // EVAL_ML_MOBILITY_H
00150
00151
00152
00153