/usr/include/osl/eval/ml/piecePair.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 | /* piecePair.h
*/
#ifndef OSL_EVAL_PIECEPAIR_H
#define OSL_EVAL_PIECEPAIR_H
#include "osl/eval/ml/weights.h"
#include "osl/eval/evalTraits.h"
#include "osl/state/numEffectState.h"
#include "osl/misc/carray3d.h"
#include <iostream>
namespace osl
{
namespace eval
{
namespace ml
{
class PiecePair
{
public:
enum {
plain_table_size = 1338,
x_table_size = 4901,
y_table_size = 7057,
DIM = plain_table_size + x_table_size + y_table_size, // 14 * 12 * PTYPEO_SIZE * PTYPEO_SIZE
};
static int eval(const NumEffectState&, const Weights&);
template<int Direction, int Offset>
static int sum12One(const Piece *basePtr,const int *xbase, const int *ybase);
static int sum12(NumEffectState const& state,Square base,PtypeO ptypeO);
template<int Direction, int Offset>
static int adjust12One(const Piece *basePtr,const int *xbase1, const int *ybase1,const int *xbase2, const int *ybase2);
static int adjust12(NumEffectState const& state,Square base,PtypeO pos,PtypeO neg);
static int evalWithUpdate(const NumEffectState& state, Move moved, int last_value, const Weights& values);
static int evalWithUpdateCompiled(const NumEffectState& state, Move moved, int last_value);
static int pieceValue(const NumEffectState& state, Piece p, const Weights& values);
static int pieceValueDouble(const NumEffectState& state, Piece p, const Weights&);
static int weight(Player attack, int index, const Weights& values)
{
return osl::eval::delta(attack) * values.value(index);
}
typedef CArray<int,3> index_t;
static index_t index(int offset_id, Piece p, Piece q);
static index_t index(int offset_id, Square p0, PtypeO o0, Square p1, PtypeO o1);
static int value(int offset_id, Piece p, Piece q, const Weights& values)
{
assert(p.isOnBoard() && q.isOnBoard());
return value(offset_id, p.square(), p.ptypeO(), q.square(), q.ptypeO(), values);
}
static int value(int offset_id, Piece p, Square p1, PtypeO o1, const Weights& values)
{
return value(offset_id, p.square(), p.ptypeO(), p1, o1, values);
}
static int value(int offset_id, Square p0, PtypeO o0, Square p1, PtypeO o1, const Weights& values)
{
assert(p0 != p1);
index_t idx = index(offset_id, p0, o0, p1, o1);
assert(idx[0] != 0); // do not forget to call init()
int ret = 0;
for (int i=0; i<3; ++i)
ret += (idx[i] > 0) ? values.value(idx[i]) : -values.value(-idx[i]);
return ret;
}
static void init();
static void sanitize(Weights& values);
/** values を展開してクラス全体で使う */
static void compile(const Weights& values);
static int valueCompiled(int offset_id, Piece p, Square p1, PtypeO o1)
{
return valueCompiled(offset_id, p.square(), p.ptypeO(), p1, o1);
}
static int valueCompiled(int offset_id, Square p0, PtypeO o0, Square p1, PtypeO o1);
// 内部用
struct IndexTable : public CArray3d<signed short, 12, PTYPEO_SIZE, PTYPEO_SIZE>
{
IndexTable();
void fillBW(int index, int dir, Ptype p0, Ptype p1);
/** for same owner */
void fillSame(int index, int dir, Ptype p0, Ptype p1);
/** for different owner */
void fillDiffer(int index, int dir, Ptype p0, Ptype p1);
static int pindex(Player player, Ptype ptype)
{
return ptypeOIndex(newPtypeO(player, ptype));
}
void amplify(int base);
};
static IndexTable plain_table;
static CArray<IndexTable, 10> x_table, y_table;
static const CArray<const Offset, 12> offsets; // offset_id -> Offset
};
}
}
}
#endif /* OSL_EVAL_ATTACKKING_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|