/usr/include/osl/eval/ml/king8.h is in libosl-dev 0.6.0-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | /* king8.h
*/
#ifndef EVAL_ML_KING8_H
#define EVAL_ML_KING8_H
#include "osl/eval/ml/weights.h"
#include "osl/eval/ml/evalStagePair.h"
#include "osl/ptype.h"
#include "osl/misc/carray.h"
#include "osl/state/numEffectState.h"
#include "osl/container/tripleInt.h"
namespace osl
{
namespace eval
{
namespace ml
{
class King8Effect
{
public:
enum { DIM = 32 + 32 + 288 + 288 };
static void setUp(const Weights &weights);
static int eval(const osl::state::NumEffectState &state);
private:
enum EffectState
{
NOT_EMPTY = -1,
NO_EFFECT = 0,
LESS_EFFECT,
MORE_EFFECT,
MORE_EFFECT_KING_ONLY
};
static CArray<int, 32> empty_table;
static CArray<int, 32> defense_table;
static CArray<int, 288> empty_y_table;
static CArray<int, 288> defense_y_table;
static int index(const Direction dir,
EffectState state);
static int indexY(Piece king,
const Direction dir,
EffectState state);
static void effectState(const NumEffectState &state,
const Player defense,
const Direction dir,
EffectState &empty,
EffectState &/*defense*/);
};
class King8EffectBase
{
public:
enum { DIM = 32 };
typedef CArray<int, 32> table_t;
enum EffectState
{
NOT_EMPTY = -1,
NO_EFFECT = 0,
LESS_EFFECT,
MORE_EFFECT,
MORE_EFFECT_KING_ONLY
};
template <class MakeEffectState>
static const CArray<int,2> evalCommon(const osl::state::NumEffectState &state, const table_t&);
template <class MakeEffectState>
static const CArray<int,2> evalWithUpdateCommon(const osl::state::NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value, const table_t&);
template <class MakeEffectState>
static std::pair<CArray<int,2>, CArray<int,2> >
evalWithUpdateCommon(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_opening, const CArray<int,2>& last_value_ending,
const table_t&, const table_t&);
struct MakeEffectStateSimple;
struct MakeEffectStateDefense;
protected:
static int index(const Direction dir, EffectState state)
{
return dir * 4 + state;
}
};
class King8EffectEmptySquareBoth;
template <bool Opening>
class King8EffectEmptySquare : public King8EffectBase
{
friend class King8EffectEmptySquareBoth;
static table_t table;
public:
static void setUp(const Weights &weights);
static const CArray<int,2> eval(const osl::state::NumEffectState &state);
static const CArray<int,2> evalWithUpdate(const osl::state::NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value);
};
class King8EffectEmptySquareBoth : public King8EffectBase
{
public:
static std::pair<CArray<int,2>, CArray<int,2> >
evalWithUpdate(const osl::state::NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_opening,
const CArray<int,2>& last_value_ending);
};
struct King8EffectEmptySquareOpening
: public King8EffectEmptySquare<true>
{
};
struct King8EffectEmptySquareEnding
: public King8EffectEmptySquare<false>
{
};
class King8EffectDefenseSquareBoth;
template <bool Opening>
class King8EffectDefenseSquare
: public King8EffectBase
{
friend class King8EffectDefenseSquareBoth;
static CArray<int, 32> table;
public:
static void setUp(const Weights &weights);
static const CArray<int,2> eval(const osl::state::NumEffectState &state);
static const CArray<int,2> evalWithUpdate(const osl::state::NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value);
};
class King8EffectDefenseSquareBoth : public King8EffectBase
{
public:
static std::pair<CArray<int,2>, CArray<int,2> >
evalWithUpdate(const osl::state::NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_opening,
const CArray<int,2>& last_value_ending);
};
struct King8EffectDefenseSquareOpening
: public King8EffectDefenseSquare<true>
{
};
struct King8EffectDefenseSquareEnding
: public King8EffectDefenseSquare<false>
{
};
class King8EffectAll
{
public:
enum { ONE_DIM = 32, DIM = 32 * 5 * 2};
private:
static CArray<int, ONE_DIM> base_table;
static CArray<int, ONE_DIM> u_table;
static CArray<int, ONE_DIM> d_table;
static CArray<int, ONE_DIM> l_table;
static CArray<int, ONE_DIM> r_table;
static CArray<int, ONE_DIM> base_defense_piece_table;
static CArray<int, ONE_DIM> u_defense_piece_table;
static CArray<int, ONE_DIM> d_defense_piece_table;
static CArray<int, ONE_DIM> l_defense_piece_table;
static CArray<int, ONE_DIM> r_defense_piece_table;
public:
enum EffectState
{
NOT_EMPTY = -1,
NO_EFFECT = 0,
LESS_EFFECT,
MORE_EFFECT,
MORE_EFFECT_KING_ONLY
};
static void setUp(const Weights &weights);
King8EffectAll() { }
static int eval(const osl::state::NumEffectState &state,
PieceMask black_mask, PieceMask white_mask);
static void effectState(const NumEffectState &state,
const Player defense,
const Direction dir,
EffectState &empty,
EffectState &/*defense*/);
static int index(const Direction dir, EffectState state);
};
struct KingXBlockedBase
{
enum { DIM = 10 };
typedef CArray<MultiInt, 10> table_t;
static const MultiIntPair eval(const NumEffectState &state,
const table_t& table);
template <osl::Player P>
static int index(Square king, int diff);
template <osl::Player P>
static bool isBlocked(const NumEffectState &state,
int diff);
#if 0
static std::pair<CArray<int,2>,CArray<int,2> >
evalWithUpdate(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_o,
const CArray<int,2>& last_value_e,
const table_t& table_o, const table_t& table_e);
#endif
};
class KingXBlockedBoth;
class KingXBlocked : public KingXBlockedBase
{
friend class KingXBlockedBoth;
friend class KingXBlockedYBase;
public:
static void setUp(const Weights &weights,int stage);
static MultiIntPair eval(const osl::state::NumEffectState &state)
{
return KingXBlockedBase::eval(state, table);
}
private:
static table_t table;
};
class KingXBlockedYBase// : public KingXBlockedBase
{
public:
enum { DIM = 90 };
typedef CArray<MultiInt, 90> table_t;
static const MultiIntPair eval(const NumEffectState &state,
const table_t& table);
static void
evalWithUpdateBang(const NumEffectState &state, Move laste_move,
MultiIntPair &last_values_and_out);
template <osl::Player P>
static int index(Square king, int diff);
private:
template <int Sign>
static void adjust(int index, int index_y, MultiInt &out);
};
class KingXBlockedY : public KingXBlockedYBase
{
friend class KingXBlockedBoth;
friend class KingXBlockedYBase;
public:
static void setUp(const Weights &weights,int stage);
static const MultiIntPair eval(const NumEffectState &state)
{
return KingXBlockedYBase::eval(state, table);
}
private:
static table_t table;
};
class KingXBlockedBoth : public KingXBlockedBase
{
public:
static void
evalWithUpdateBang(const NumEffectState &new_state, Move last_move,
MultiIntPair& last_values_and_out);
};
class KingXBothBlocked
{
friend class KingXBlockedYBase;
public:
enum { ONE_DIM = 5, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
static MultiIntPair eval(const NumEffectState &state);
private:
static CArray<MultiInt, ONE_DIM> table;
static int index(const Square king)
{
const int x = king.x();
return (x > 5 ? 9 - x : x - 1);;
}
template <Player P>
static int indexY(const Square king)
{
const int x = king.x();
const int y = (P == BLACK ? king.y() : 10 - king.y());
return (y - 1) * 5 + (x > 5 ? 9 - x : x - 1);
}
template <int Sign>
static void adjust(int index, int index_y, MultiInt &out);
};
class KingXBothBlockedY
{
friend class KingXBlockedYBase;
friend class KingXBothBlocked;
public:
enum { ONE_DIM = 5 * 9, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
private:
static CArray<MultiInt, ONE_DIM> table;
};
class KingXBlocked3
{
friend class KingXBlocked3Y;
public:
enum { ONE_DIM = 80, DIM = ONE_DIM * EvalStages };
static MultiInt eval(const NumEffectState &state);
static void setUp(const Weights &weights);
private:
template <int Sign>
static void adjust(int index_y, MultiInt &result)
{
if(Sign>0)
result += y_table[index_y];
else
result -= y_table[index_y];
}
template <Player P>
static int index(const Square king, bool is_l,
bool u_blocked, bool opp_u_blocked, bool opp_blocked)
{
int x = king.x();
if (x >= 6)
{
x = 10 - x;
if (P == BLACK)
{
is_l = !is_l;
}
}
else if (P == WHITE && x <= 4)
{
is_l = !is_l;
}
return x - 1 + 5 * ((is_l ? 1 : 0) + 2 * ((u_blocked ? 1 : 0) + 2 * ((opp_u_blocked ? 1 : 0) +2 * (opp_blocked ? 1 : 0))));
}
template <Player P>
static int indexY(const Square king, bool is_l,
bool u_blocked, bool opp_u_blocked,
bool opp_blocked)
{
int x = king.x();
const int y = (P == BLACK ? king.y() : 10 - king.y());
if (x >= 6)
{
x = 10 - x;
if (P == BLACK)
{
is_l = !is_l;
}
}
else if (P == WHITE && x <= 4)
{
is_l = !is_l;
}
return x - 1 + 5 * (y - 1 + 9 * ((is_l ? 1 : 0) + 2 * ((u_blocked ? 1 : 0) + 2 * ((opp_u_blocked ? 1 : 0) + 2 * (opp_blocked ? 1 : 0)))));
}
static CArray<MultiInt, 80> table;
static CArray<MultiInt, 720> y_table;
};
class KingXBlocked3Y
{
public:
enum { ONE_DIM = 720, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
class AnagumaEmpty
{
public:
enum { DIM = 4 };
static void setUp(const Weights &weights,int stage);
static MultiInt eval(const osl::state::NumEffectState &state);
static int index(Square king, Square target);
template <osl::Player Defense>
static MultiInt evalOne(const NumEffectState &state);
private:
static CArray<MultiInt, 4> table;
};
}
}
}
#endif // EVAL_ML_KING8_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|