feature/escape.h
Go to the documentation of this file.
/* escape.h
*/
#ifndef _ESCAPE_H
#define _ESCAPE_H
#include "osl/rating/feature.h"
#include "osl/rating/feature/countEffect2.h"
namespace osl
{
namespace rating
{
class FromEffect : public Feature, CountEffect2
{
public:
FromEffect(int attack, int defense)
: Feature("FE"+CountEffect2::name(attack, defense)), CountEffect2(attack, defense) {}
bool match(const NumEffectState& state, Move move, const RatingEnv& env) const
{
return ! move.isDrop() && CountEffect2::match(state, move.from(), env);
}
};
class PtypeAttacked : public Feature
{
Ptype self, attack;
public:
PtypeAttacked(Ptype s, Ptype a)
: Feature(std::string(Ptype_Table.getCsaName(s))+"<"+Ptype_Table.getCsaName(a)),
self(s), attack(a)
{
}
bool match(const NumEffectState& state, Move move, const RatingEnv&) const
{
return move.oldPtype() == self
&& ! move.isDrop()
&& state.findCheapAttack(alt(move.player()), move.from()).ptype()== attack;
}
};
class ToSupported : public Feature
{
public:
ToSupported() : Feature("TS") {}
bool match(const NumEffectState& state, Move move, const RatingEnv&) const
{
return state.hasEffectAt(move.player(), move.to());
}
};
class ImmediateEscape : public Feature
{
Ptype self, attack;
public:
ImmediateEscape(Ptype s, Ptype a)
: Feature(std::string(Ptype_Table.getCsaName(s))+"<"+Ptype_Table.getCsaName(a)),
self(s), attack(a)
{
}
bool match(const NumEffectState& state, Move move, const RatingEnv& env) const
{
if (move.isDrop())
return false;
if (move.ptype() != self)
return false;
const Move last_move = env.history.lastMove();
if (! last_move.isNormal() || last_move.ptype() != attack)
return false;
return state.hasEffectIf(last_move.ptypeO(), last_move.to(), move.from());
}
};
class KingEscape : public Feature
{
Ptype ptype;
public:
KingEscape(Ptype s)
: Feature(std::string(Ptype_Table.getCsaName(s))), ptype(s)
{
}
bool match(const NumEffectState& state, Move move, const RatingEnv&) const
{
return state.inCheck()
&& move.ptype() == ptype;
}
bool effectiveInCheck() const { return true; }
};
}
}
#endif /* _ESCAPE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::ptypeO
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Definition basic_type.h:1162
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::Move::player
Player player() const
Definition basic_type.h:1195
osl::Move::isDrop
bool isDrop() const
Definition basic_type.h:1150
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition basic_type.h:1088
osl::Move::oldPtype
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
Definition basic_type.h:1174
osl::Move::to
const Square to() const
Definition basic_type.h:1132
osl::Move::from
const Square from() const
Definition basic_type.h:1125
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::hasEffectAt
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
Definition numEffectState.h:324
osl::NumEffectState::findCheapAttack
const Piece findCheapAttack(Player P, Square square) const
Definition numEffectState.h:560
osl::NumEffectState::hasEffectIf
bool hasEffectIf(PtypeO ptypeo, Square attacker, Square target) const
attackerにptypeoの駒がいると仮定した場合にtargetに利きがあるかどうか を stateをupdateしないで確かめる.
Definition numEffectState.h:465
osl::NumEffectState::inCheck
bool inCheck(Player P) const
Pの玉が王手状態
Definition numEffectState.h:88
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::container::MoveStack::lastMove
const Move lastMove(size_t last=1) const
Definition moveStack.h:28
osl::rating::Feature::Feature
Feature(const std::string &name)
Definition rating/feature.h:18
osl::rating::Feature::name
const std::string & name() const
Definition rating/feature.h:24
osl::rating::FromEffect::FromEffect
FromEffect(int attack, int defense)
Definition feature/escape.h:17
osl::rating::FromEffect::match
bool match(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition feature/escape.h:19
osl::rating::ImmediateEscape::match
bool match(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition feature/escape.h:61
osl::rating::ImmediateEscape::self
Ptype self
Definition feature/escape.h:54
osl::rating::ImmediateEscape::attack
Ptype attack
Definition feature/escape.h:54
osl::rating::ImmediateEscape::ImmediateEscape
ImmediateEscape(Ptype s, Ptype a)
Definition feature/escape.h:56
osl::rating::KingEscape::match
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition feature/escape.h:82
osl::rating::KingEscape::KingEscape
KingEscape(Ptype s)
Definition feature/escape.h:78
osl::rating::KingEscape::ptype
Ptype ptype
Definition feature/escape.h:76
osl::rating::KingEscape::effectiveInCheck
bool effectiveInCheck() const
Definition feature/escape.h:87
osl::rating::PtypeAttacked::attack
Ptype attack
Definition feature/escape.h:27
osl::rating::PtypeAttacked::PtypeAttacked
PtypeAttacked(Ptype s, Ptype a)
Definition feature/escape.h:29
osl::rating::PtypeAttacked::self
Ptype self
Definition feature/escape.h:27
osl::rating::PtypeAttacked::match
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition feature/escape.h:34
osl::rating::RatingEnv
Definition ratingEnv.h:16
osl::rating::RatingEnv::history
MoveStack history
Definition ratingEnv.h:18
osl::rating::ToSupported::match
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition feature/escape.h:46
osl::rating::ToSupported::ToSupported
ToSupported()
Definition feature/escape.h:45
countEffect2.h
osl::rating
Definition construct.h:18
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition tables.cc:97
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
std
Definition basic_type.h:1353
feature.h
osl::rating::CountEffect2::CountEffect2
CountEffect2(int a, int d)
Definition countEffect2.h:18
osl::rating::CountEffect2::match
bool match(const NumEffectState &state, Square position, const RatingEnv &env) const
Definition countEffect2.h:37
osl::rating::CountEffect2::attack
int attack
Definition countEffect2.h:17
osl::rating::CountEffect2::defense
int defense
Definition countEffect2.h:17