My Project
feature/escape.h
Go to the documentation of this file.
1/* escape.h
2 */
3#ifndef _ESCAPE_H
4#define _ESCAPE_H
5
8
9namespace osl
10{
11 namespace rating
12 {
15 {
16 public:
19 bool match(const NumEffectState& state, Move move, const RatingEnv& env) const
20 {
21 return ! move.isDrop() && CountEffect2::match(state, move.from(), env);
22 }
23 };
24
25 class PtypeAttacked : public Feature
26 {
28 public:
30 : Feature(std::string(Ptype_Table.getCsaName(s))+"<"+Ptype_Table.getCsaName(a)),
31 self(s), attack(a)
32 {
33 }
34 bool match(const NumEffectState& state, Move move, const RatingEnv&) const
35 {
36 return move.oldPtype() == self
37 && ! move.isDrop()
38 && state.findCheapAttack(alt(move.player()), move.from()).ptype()== attack;
39 }
40 };
41
42 class ToSupported : public Feature
43 {
44 public:
45 ToSupported() : Feature("TS") {}
46 bool match(const NumEffectState& state, Move move, const RatingEnv&) const
47 {
48 return state.hasEffectAt(move.player(), move.to());
49 }
50 };
51
52 class ImmediateEscape : public Feature
53 {
55 public:
57 : Feature(std::string(Ptype_Table.getCsaName(s))+"<"+Ptype_Table.getCsaName(a)),
58 self(s), attack(a)
59 {
60 }
61 bool match(const NumEffectState& state, Move move, const RatingEnv& env) const
62 {
63 if (move.isDrop())
64 return false;
65 if (move.ptype() != self)
66 return false;
67 const Move last_move = env.history.lastMove();
68 if (! last_move.isNormal() || last_move.ptype() != attack)
69 return false;
70 return state.hasEffectIf(last_move.ptypeO(), last_move.to(), move.from());
71 }
72 };
73
74 class KingEscape : public Feature
75 {
77 public:
79 : Feature(std::string(Ptype_Table.getCsaName(s))), ptype(s)
80 {
81 }
82 bool match(const NumEffectState& state, Move move, const RatingEnv&) const
83 {
84 return state.inCheck()
85 && move.ptype() == ptype;
86 }
87 bool effectiveInCheck() const { return true; }
88 };
89 }
90}
91
92#endif /* _ESCAPE_H */
93// ;;; Local Variables:
94// ;;; mode:c++
95// ;;; c-basic-offset:2
96// ;;; End:
圧縮していない moveの表現 .
Definition: basic_type.h:1052
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Definition: basic_type.h:1162
Ptype ptype() const
Definition: basic_type.h:1155
Player player() const
Definition: basic_type.h:1195
bool isDrop() const
Definition: basic_type.h:1150
bool isNormal() const
INVALID でも PASS でもない.
Definition: basic_type.h:1088
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
Definition: basic_type.h:1174
const Square to() const
Definition: basic_type.h:1132
const Square from() const
Definition: basic_type.h:1125
利きを持つ局面
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
const Piece findCheapAttack(Player P, Square square) const
bool hasEffectIf(PtypeO ptypeo, Square attacker, Square target) const
attackerにptypeoの駒がいると仮定した場合にtargetに利きがあるかどうか を stateをupdateしないで確かめる.
bool inCheck(Player P) const
Pの玉が王手状態
Ptype ptype() const
Definition: basic_type.h:821
const Move lastMove(size_t last=1) const
Definition: moveStack.h:28
const std::string & name() const
移動元へのきき。attack defense は言葉の意味と逆で自分がattack
FromEffect(int attack, int defense)
bool match(const NumEffectState &state, Move move, const RatingEnv &env) const
bool match(const NumEffectState &state, Move move, const RatingEnv &env) const
ImmediateEscape(Ptype s, Ptype a)
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
bool effectiveInCheck() const
PtypeAttacked(Ptype s, Ptype a)
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
const PtypeTable Ptype_Table
Definition: tables.cc:97
constexpr Player alt(Player player)
Definition: basic_type.h:13
bool match(const NumEffectState &state, Square position, const RatingEnv &env) const
Definition: countEffect2.h:37