My Project
capture.h
Go to the documentation of this file.
1/* capture.h
2 */
3#ifndef _CAPTURE_H
4#define _CAPTURE_H
5
7#include "osl/eval/see.h"
10
11namespace 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()
80 }
81 };
82
83 }
84}
85
86
87#endif /* _CAPTURE_H */
88// ;;; Local Variables:
89// ;;; mode:c++
90// ;;; c-basic-offset:2
91// ;;; End:
圧縮していない moveの表現 .
Ptype ptype() const
Player player() const
bool isDrop() const
Ptype capturePtype() const
bool isNormal() const
INVALID でも PASS でもない.
const Square to() const
const Square from() const
利きを持つ局面
bool hasLastMove(size_t last=1) const
Definition moveStack.h:27
const Move lastMove(size_t last=1) const
Definition moveStack.h:28
bool match(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition capture.h:30
Capture(int f, int l)
Definition capture.h:23
static int see(const NumEffectState &state, Move move, const RatingEnv &env)
Definition capture.h:24
bool match(const NumEffectState &, Move move, const RatingEnv &env) const
Definition capture.h:61
取った駒をすぐ使う
Definition capture.h:70
bool match(const NumEffectState &, Move move, const RatingEnv &env) const
Definition capture.h:74
const std::string & name() const
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition capture.h:41
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition capture.h:51
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
@ PTYPE_EMPTY
Definition basic_type.h:85
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition basic_type.h:157
static int count2(const NumEffectState &, Square target, Player attack)
target に attack の影利きを二つまで数える.
static int see(const NumEffectState &state, Move move, const PieceMask &my_pin=PieceMask(), const PieceMask &op_pin=PieceMask(), const PtypeEvalTable *table=0)
Definition see.cc:261