My Project
captureGroup.h
Go to the documentation of this file.
1/* captureGroup.h
2 */
3#ifndef _CAPTUREGROUP_H
4#define _CAPTUREGROUP_H
5
6#include "osl/rating/group.h"
8
9namespace osl
10{
11 namespace rating
12 {
13 class CaptureGroup : public Group
14 {
15 public:
16 std::vector<int> see_range;
18 void show(std::ostream& os, int name_width, const range_t& range,
19 const std::vector<double>& weights) const
20 {
21 showAll(os, name_width, range, weights);
22 }
23 int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
24 {
25 const int progress8 = env.progress.value()/2;
26 const int see = Capture::see(state, move, env);
27 size_t index;
28 if (see > 50)
29 index = std::min(12, 7 + (see - 51) / 200);
30 else if (see < -50)
31 index = std::max(0, (see + 1250) / 200);
32 else
33 index = 6;
34#ifndef NDEBUG
35 for (size_t i=0; i<see_range.size()-1; ++i) {
36 if (see < see_range[i+1]) {
37 assert(i == index);
38 return i*8+progress8;
39 }
40 }
41 assert(0);
42 abort();
43#endif
44 return index*8+progress8;
45 }
46 bool effectiveInCheck() const { return true; }
47 };
48
49 struct ShadowEffectGroup : public Group
50 {
51 ShadowEffectGroup() : Group("ShadowEffect")
52 {
53 push_back(new ShadowEffect1());
54 push_back(new ShadowEffect2());
55 }
56 void show(std::ostream& os, int name_width, const range_t& range,
57 const std::vector<double>& weights) const
58 {
59 showAll(os, name_width, range, weights);
60 }
61 int findMatch(const NumEffectState& state, Move move, const RatingEnv&) const
62 {
63 return ShadowEffect::count2(state, move.to(), move.player()) -1;
64 }
65 };
66
68 {
69 ContinueCaptureGroup() : Group("Cont.Capture")
70 {
71 for (int p=0; p<8; ++p) // progress8
72 push_back(new ContinueCapture());
73 }
74 void show(std::ostream& os, int name_width, const range_t& range,
75 const std::vector<double>& weights) const
76 {
77 showAll(os, name_width, range, weights);
78 }
79 int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
80 {
81 if (! (*this)[0].match(state, move, env))
82 return -1;
83 const int progress8 = env.progress.value()/2;
84 return progress8;
85 }
86 };
87
88 struct DropCapturedGroup : public Group
89 {
91 void show(std::ostream& os, int name_width, const range_t& range,
92 const std::vector<double>& weights) const
93 {
94 showTopN(os, name_width, range, weights, 3);
95 }
96 int findMatchWithoutProgress(Move move, const RatingEnv& env) const
97 {
98 if (! (move.isDrop() && env.history.hasLastMove(2)))
99 return -1;
100 const Move last2_move = env.history.lastMove(2);
101 if (! (last2_move.isNormal()
102 && last2_move.capturePtype() != PTYPE_EMPTY
103 && unpromote(last2_move.capturePtype()) == move.ptype()))
104 return -1;
105 return move.ptype() - PTYPE_BASIC_MIN;
106 }
107 int findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
108 {
109 const int index = findMatchWithoutProgress(move, env);
110 if (index < 0)
111 return index;
112 const int progress8 = env.progress.value()/2;
113 return index*8 + progress8;
114 }
115 };
116 }
117}
118
119
120#endif /* _CAPTUREGROUP_H */
121// ;;; Local Variables:
122// ;;; mode:c++
123// ;;; c-basic-offset:2
124// ;;; End:
圧縮していない moveの表現 .
Ptype ptype() const
Player player() const
bool isDrop() const
Ptype capturePtype() const
bool isNormal() const
INVALID でも PASS でもない.
const Square to() const
利きを持つ局面
bool hasLastMove(size_t last=1) const
Definition moveStack.h:27
const Move lastMove(size_t last=1) const
Definition moveStack.h:28
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
bool effectiveInCheck() const
std::vector< int > see_range
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
static int see(const NumEffectState &state, Move move, const RatingEnv &env)
Definition capture.h:24
mutually exclusive set of features
Definition group.h:17
void showAll(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition group.cc:74
void showTopN(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights, int n) const
Definition group.cc:100
std::pair< int, int > range_t
Definition range.h:10
@ PTYPE_EMPTY
Definition basic_type.h:85
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition basic_type.h:157
static int count2(const NumEffectState &, Square target, Player attack)
target に attack の影利きを二つまで数える.
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
int findMatchWithoutProgress(Move move, const RatingEnv &env) const
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
int findMatch(const NumEffectState &, Move move, const RatingEnv &env) const
int findMatch(const NumEffectState &state, Move move, const RatingEnv &) const
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const