All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mobility.h
Go to the documentation of this file.
1 /* mobility.h
2  */
3 
4 #ifndef EVAL_ML_MOBILITY_H
5 #define EVAL_ML_MOBILITY_H
6 
7 #include "osl/eval/ml/weights.h"
8 #include "osl/eval/ml/midgame.h"
9 #include "osl/ptype.h"
10 #include "osl/misc/carray.h"
13 
14 namespace osl
15 {
16  namespace eval
17  {
18  namespace ml
19  {
21  {
22  friend class RookMobility;
23  friend class RookMobilityX;
24  friend class RookMobilityY;
25  friend class RookMobilitySum;
26  friend class RookMobilitySumKingX;
27  friend class RookMobilityXKingX;
28  public:
29  template<int Sign>
30  static void adjust(const NumEffectState&, bool promoted,
31  int vertical, int horizontal,
32  Square pos,
33  MultiInt& value);
34  static void eval(const NumEffectState&, MultiInt& out);
35  private:
36  static int indexX(Square rook, bool promoted,
37  int count, bool vertical)
38  {
39  const int x = (rook.x() > 5 ?
40  10 - rook.x() : rook.x());
41  return x - 1 + 5 * ((promoted ? 1 : 0) +
42  2 * ((vertical ? 1 : 0) + 2 * count));
43  }
44  template <int Sign>
45  static int indexY(Square rook, bool promoted,
46  int count, bool vertical)
47  {
48  const int y = (Sign > 0 ? rook.y() : 10 - rook.y());
49  return y - 1 + 9 * ((promoted ? 1 : 0) +
50  2 * ((vertical ? 1 : 0) + 2 * count));
51  }
52  template <int Sign>
53  static int indexXKingX(Square rook, Square king, int count, bool vertical)
54  {
55  const Square r = (Sign > 0) ? rook : rook.rotate180();
56  const Square k = (Sign > 0) ? king : king.rotate180();
57  const bool flip = r.x() > 5;
58  const int x = (flip ? 10 - r.x() : r.x());
59  const int king_x = (flip ? 10 - k.x() : k.x());
60  return king_x - 1 + 9 * (x - 1 + 5 * ((vertical ? 1 : 0) + 2 * count));
61  }
62  static CArray<MultiInt, 18> rook_vertical_table;
63  static CArray<MultiInt, 18> rook_horizontal_table;
64  static CArray<MultiInt, 34> sum_table;
65  static CArray<MultiInt, 324> x_table;
66  static CArray<MultiInt, 324> y_table;
67  static CArray<MultiInt, 17 * 9> sumkingx_table;
68  static CArray<MultiInt, 9 * 2 * 5 * 9> xkingx_table;
69  };
70 
72  {
73  public:
74  enum { DIM = 36 };
75  static void setUp(const Weights &weights,int stage);
76  };
77 
79  {
80  public:
81  enum { ONE_DIM = 34, DIM = ONE_DIM * EvalStages };
82  static void setUp(const Weights &weights);
83  };
85  {
86  public:
87  enum { ONE_DIM = 180, DIM = ONE_DIM * EvalStages };
88  static void setUp(const Weights &weights);
89  };
91  {
92  public:
93  enum { ONE_DIM = 324, DIM = ONE_DIM * EvalStages };
94  static void setUp(const Weights &weights);
95  };
97  {
98  public:
99  enum { ONE_DIM = 17 * 9, DIM = ONE_DIM * EvalStages };
100  static void setUp(const Weights &weights);
101  };
103  {
104  public:
105  enum { ONE_DIM = 9 * 2 * 5 * 9, DIM = ONE_DIM * EvalStages };
106  static void setUp(const Weights &weights);
107  };
108 
110  {
111  friend class BishopMobility;
112  friend class BishopMobilityEach;
113  public:
114  template<int Sign>
115  static void adjust(bool promoted, int mobility1, int mobility2,
116  MultiInt& value);
117  static void eval(const NumEffectState&, MultiInt& out);
118  private:
119  static CArray<MultiInt, 36> bishop_table;
120  static CArray<MultiInt, 18> each_table;
121  };
123  {
124  public:
125  enum { DIM = 36 };
126  static void setUp(const Weights &weights,int stage);
127  };
129  {
130  public:
131  enum { ONE_DIM = 18, DIM = ONE_DIM * EvalStages };
132  static void setUp(const Weights &weights);
133  };
135  {
136  template<int Sign>
137  static void adjust(int index, MultiInt& value);
138  static void eval(const NumEffectState&, MultiInt& out);
139  };
141  {
142  static CArray<MultiInt, 9> lance_table;
143  friend struct LanceMobilityAll;
144  public:
145  enum { DIM = 9 };
147  static void setUp(const Weights &weights,int stage);
148  };
149  }
150  }
151 }
152 #endif // EVAL_ML_MOBILITY_H
153 // ;;; Local Variables:
154 // ;;; mode:c++
155 // ;;; c-basic-offset:2
156 // ;;; End: