captureGroup.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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"
7 #include "osl/rating/feature/capture.h"
8
9 namespace osl
10 {
11 namespace rating
12 {
13 class CaptureGroup : public Group
14 {
15 public:
16 vector<int> see_range;
17 CaptureGroup();
18 void show(std::ostream& os, int name_width, const range_t& range,
19 const 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 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
67 struct ContinueCaptureGroup : public Group
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 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 {
90 DropCapturedGroup();
91 void show(std::ostream& os, int name_width, const range_t& range,
92 const 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: