Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
rating
feature
feature/escape.h
Go to the documentation of this file.
1
/* escape.h
2
*/
3
#ifndef _ESCAPE_H
4
#define _ESCAPE_H
5
6
#include "
osl/rating/feature.h
"
7
#include "
osl/rating/feature/countEffect2.h
"
8
9
namespace
osl
10
{
11
namespace
rating
12
{
14
class
FromEffect
:
public
Feature
,
CountEffect2
15
{
16
public
:
17
FromEffect
(
int
attack
,
int
defense
)
18
:
Feature
(
"FE"
+
CountEffect2
::
name
(attack, defense)),
CountEffect2
(attack, defense) {}
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
{
27
Ptype
self
,
attack
;
28
public
:
29
PtypeAttacked
(
Ptype
s,
Ptype
a)
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
{
54
Ptype
self
,
attack
;
55
public
:
56
ImmediateEscape
(
Ptype
s,
Ptype
a)
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
{
76
Ptype
ptype
;
77
public
:
78
KingEscape
(
Ptype
s)
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:
Generated on Sun Jul 21 2013 13:37:24 by
1.8.4