All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
capture.h
Go to the documentation of this file.
1 /* capture.h
2  */
3 #ifndef _CAPTURE_H
4 #define _CAPTURE_H
5 
6 #include "osl/rating/feature.h"
7 #include "osl/eval/see.h"
10 
11 namespace osl
12 {
13  namespace rating
14  {
15  class Capture : public Feature
16  {
17  public:
18  enum { INF = 999999 };
19  private:
20  int first, last;
21  static const std::string name(int first, int last);
22  public:
23  Capture(int f, int l) : Feature(name(f, l)), first(f), last(l) {}
24  static int see(const NumEffectState& state, Move move, const RatingEnv& env)
25  {
26  int see = See::see(state, move, env.my_pin, env.op_pin);
27  see = see*100/128;
28  return see;
29  }
30  bool match(const NumEffectState& state, Move move, const RatingEnv& env) const
31  {
32  int see = this->see(state, move, env);
33  return first <= see && see < last;
34  }
35  };
36 
37  class ShadowEffect1 : public Feature
38  {
39  public:
40  ShadowEffect1() : Feature("ShadowEffect1") {}
41  bool match(const NumEffectState& state, Move move, const RatingEnv&) const
42  {
43  return ShadowEffect::count2(state, move.to(), move.player()) == 1;
44  }
45  };
46 
47  class ShadowEffect2 : public Feature
48  {
49  public:
50  ShadowEffect2() : Feature("ShadowEffect2") {}
51  bool match(const NumEffectState& state, Move move, const RatingEnv&) const
52  {
53  return ShadowEffect::count2(state, move.to(), move.player()) == 2;
54  }
55  };
56 
57  class ContinueCapture : public Feature
58  {
59  public:
60  ContinueCapture() : Feature("Cont.C") {}
61  bool match(const NumEffectState&, Move move, const RatingEnv& env) const
62  {
63  return env.history.hasLastMove(2) && env.history.lastMove(2).to() == move.from()
64  && move.capturePtype() != PTYPE_EMPTY;
65  }
66  };
67 
69  class DropCaptured : public Feature
70  {
72  public:
74  bool match(const NumEffectState&, Move move, const RatingEnv& env) const
75  {
76  return move.isDrop() && move.ptype() == ptype
77  && env.history.hasLastMove(2) && env.history.lastMove(2).isNormal()
78  && env.history.lastMove(2).capturePtype() != PTYPE_EMPTY
79  && unpromote(env.history.lastMove(2).capturePtype()) == ptype;
80  }
81  };
82 
83  }
84 }
85 
86 
87 #endif /* _CAPTURE_H */
88 // ;;; Local Variables:
89 // ;;; mode:c++
90 // ;;; c-basic-offset:2
91 // ;;; End: