My Project
piecePairKing.h
Go to the documentation of this file.
1/* piecePairKing.h
2 */
3#ifndef OSL_EVAL_ML_PIECEPAIRKING_H
4#define OSL_EVAL_ML_PIECEPAIRKING_H
5
7namespace osl
8{
9 namespace eval
10 {
11 namespace ml
12 {
13 struct Weights;
15 {
16 public:
17 enum
18 {
19 ONE_DIM = 1488375,
20 DIM = ONE_DIM
21 };
22 static void setUp(const Weights &weights);
23 static CArray<int,2> eval(const NumEffectState&);
24 template <Player P>
25 static void evalWithUpdateBang(const NumEffectState& state, Move moved, CArray<int,2>& last_value);
26
27 template <Player King>
28 static int evalOne(const NumEffectState&);
29 private:
30 template <Player King>
31 static int add(const NumEffectState& state, Square to, Ptype ptype);
32 template <Player King>
33 static int sub(const NumEffectState& state, Square from, Ptype ptype);
34 template <Player King>
35 static int addSub(const NumEffectState& state, Square to, Ptype ptype, Square from);
36 static int composeIndex(int king, int i0, int i1)
37 {
38 return king + i0*45*7 + i1;
39 }
40 static int indexWhite(Square p)
41 {
42 return p.x()-1 + (p.y()-1)*9;
43 }
44 static int indexKing(Player owner, Square king, bool& flipx)
45 {
46 if (owner == BLACK)
47 king = king.rotate180();
48 assert(king.y() <= 3);
49 if (king.x() > 5)
50 {
51 king = king.flipHorizontal();
52 flipx = true;
53 }
54 else
55 flipx = false;
56 return (king.x()-1 + (king.y()-1)*5)*45*7*45*7;
57 }
58 template <bool FlipX>
59 static int indexPiece(Player owner, Square position, Ptype ptype)
60 {
61 assert(! isPromoted(ptype));
62 if (owner == BLACK)
63 position = position.rotate180();
64 if (FlipX)
65 position = position.flipHorizontal();
66 assert(position.y() <= 5);
67 return indexWhite(position)*7 + ptype-PTYPE_BASIC_MIN-1;
68 }
70 };
71 }
72 }
73}
74
75
76#endif /* OSL_EVAL_ML_PIECEPAIRKING_H */
77// ;;; Local Variables:
78// ;;; mode:c++
79// ;;; c-basic-offset:2
80// ;;; End:
圧縮していない moveの表現 .
利きを持つ局面
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
const Square rotate180() const
Definition basic_type.h:613
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
const Square flipHorizontal() const
Definition basic_type.h:628
static int indexWhite(Square p)
static int add(const NumEffectState &state, Square to, Ptype ptype)
static void setUp(const Weights &weights)
static int addSub(const NumEffectState &state, Square to, Ptype ptype, Square from)
static void evalWithUpdateBang(const NumEffectState &state, Move moved, CArray< int, 2 > &last_value)
static int composeIndex(int king, int i0, int i1)
static int evalOne(const NumEffectState &)
static osl::CArray< int16_t, ONE_DIM > table
static int sub(const NumEffectState &state, Square from, Ptype ptype)
static int indexKing(Player owner, Square king, bool &flipx)
static int indexPiece(Player owner, Square position, Ptype ptype)
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
Definition basic_type.h:137
Player
Definition basic_type.h:8
@ BLACK
Definition basic_type.h:9