My Project
pinGroup.h
Go to the documentation of this file.
1/* pinGroup.h
2 */
3#ifndef _PINGROUP_H
4#define _PINGROUP_H
5
6#include "osl/rating/group.h"
8
9namespace osl
10{
11 namespace rating
12 {
13 struct PinGroup : public Group
14 {
15 PinGroup() : Group("PinAttack")
16 {
17 for (int s = PTYPE_PIECE_MIN; s<= PTYPE_MAX; ++s) {
18 for (int t = PTYPE_PIECE_MIN; t<= PTYPE_MAX; ++t) {
19 const Ptype self = static_cast<Ptype>(s);
20 const Ptype target = static_cast<Ptype>(t);
21 for (int p=0; p<8; ++p) // progress8
22 push_back(new PinAttack(true, self, target));
23 for (int p=0; p<8; ++p) // progress8
24 push_back(new PinAttack(false, self, target));
25 }
26 }
27 }
28 void show(std::ostream& os, int name_width, const range_t& range,
29 const std::vector<double>& weights) const
30 {
31 showTopN(os, name_width, range, weights, 3);
32 }
33 int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
34 {
35 const int progress8 = env.progress.value()/2;
36 const int attack_index = PinAttack::index(state, move, env, true);
37 if (attack_index >= 0)
38 return attack_index*8 + progress8;
39 const int defense_index = PinAttack::index(state, move, env, false);
40 if (defense_index >= 0)
41 return defense_index*8 + progress8;
42 return -1;
43 }
44 };
45
46 struct EscapePinGroup : public Group
47 {
48 EscapePinGroup() : Group("EscapePin")
49 {
50 for (int s = PTYPE_BASIC_MIN+1; s<= PTYPE_MAX; ++s) {
51 const Ptype self = static_cast<Ptype>(s);
52 for (int p=0; p<8; ++p) // progress8
53 push_back(new EscapePin(self));
54 }
55 }
56 void show(std::ostream& os, int name_width, const range_t& range,
57 const std::vector<double>& weights) const
58 {
59 showTopN(os, name_width, range, weights, 3);
60 }
61 int findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
62 {
63 if (move.ptype() != KING || ! env.my_pin.any())
64 return -1;
65 int s;
66 for (s = PTYPE_BASIC_MIN+1; s<= PTYPE_MAX; ++s) {
67 const Ptype pinned = static_cast<Ptype>(s);
68 if ((env.my_pin.getMask(Ptype_Table.getIndex(pinned))
69 & Ptype_Table.getMaskLow(pinned)).any())
70 break;
71 }
72 s -= PTYPE_BASIC_MIN+1;
73 assert(s >= 0);
74 const int progress8 = env.progress.value()/2;
75 return s*8 + progress8;
76 }
77 };
78 }
79}
80
81
82#endif /* _PINGROUP_H */
83// ;;; Local Variables:
84// ;;; mode:c++
85// ;;; c-basic-offset:2
86// ;;; End:
圧縮していない moveの表現 .
Ptype ptype() const
利きを持つ局面
const mask_t getMask(int num) const
Definition pieceMask.h:59
bool any() const
Definition pieceMask.h:57
int getIndex(Ptype) const
Definition ptypeTable.h:50
mask_t getMaskLow(Ptype ptype) const
Definition ptypeTable.h:46
mutually exclusive set of features
Definition group.h:17
void showTopN(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights, int n) const
Definition group.cc:100
static int index(const NumEffectState &state, Move move, const RatingEnv &, bool attack, Piece p)
Definition pinAttack.h:45
std::pair< int, int > range_t
Definition range.h:10
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
@ PTYPE_PIECE_MIN
Definition basic_type.h:104
@ PTYPE_MAX
Definition basic_type.h:105
@ KING
Definition basic_type.h:93
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
const PtypeTable Ptype_Table
Definition tables.cc:97
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition pinGroup.h:56
int findMatch(const NumEffectState &, Move move, const RatingEnv &env) const
Definition pinGroup.h:61
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition pinGroup.h:28
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition pinGroup.h:33