capture.h
Go to the documentation of this file.
/* capture.h
*/
#ifndef _CAPTURE_H
#define _CAPTURE_H
#include "osl/rating/feature.h"
#include "osl/eval/see.h"
#include "osl/effect_util/shadowEffect.h"
#include "osl/additionalEffect.h"
namespace osl
{
namespace rating
{
class Capture : public Feature
{
public:
enum { INF = 999999 };
private:
int first, last;
static const std::string name(int first, int last);
public:
Capture(int f, int l) : Feature(name(f, l)), first(f), last(l) {}
static int see(const NumEffectState& state, Move move, const RatingEnv& env)
{
int see = See::see(state, move, env.my_pin, env.op_pin);
see = see*100/128;
return see;
}
bool match(const NumEffectState& state, Move move, const RatingEnv& env) const
{
int see = this->see(state, move, env);
return first <= see && see < last;
}
};
class ShadowEffect1 : public Feature
{
public:
ShadowEffect1() : Feature("ShadowEffect1") {}
bool match(const NumEffectState& state, Move move, const RatingEnv&) const
{
return ShadowEffect::count2(state, move.to(), move.player()) == 1;
}
};
class ShadowEffect2 : public Feature
{
public:
ShadowEffect2() : Feature("ShadowEffect2") {}
bool match(const NumEffectState& state, Move move, const RatingEnv&) const
{
return ShadowEffect::count2(state, move.to(), move.player()) == 2;
}
};
class ContinueCapture : public Feature
{
public:
ContinueCapture() : Feature("Cont.C") {}
bool match(const NumEffectState&, Move move, const RatingEnv& env) const
{
return env.history.hasLastMove(2) && env.history.lastMove(2).to() == move.from()
&& move.capturePtype() != PTYPE_EMPTY;
}
};
class DropCaptured : public Feature
{
Ptype ptype;
public:
DropCaptured(Ptype ptype);
bool match(const NumEffectState&, Move move, const RatingEnv& env) const
{
return move.isDrop() && move.ptype() == ptype
&& env.history.hasLastMove(2) && env.history.lastMove(2).isNormal()
&& env.history.lastMove(2).capturePtype() != PTYPE_EMPTY
&& unpromote(env.history.lastMove(2).capturePtype()) == ptype;
}
};
}
}
#endif /* _CAPTURE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
additionalEffect.h
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
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::capturePtype
Ptype capturePtype() const
Definition basic_type.h:1180
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition basic_type.h:1088
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::container::MoveStack::hasLastMove
bool hasLastMove(size_t last=1) const
Definition moveStack.h:27
osl::container::MoveStack::lastMove
const Move lastMove(size_t last=1) const
Definition moveStack.h:28
osl::rating::Capture::match
bool match(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition capture.h:30
osl::rating::Capture::Capture
Capture(int f, int l)
Definition capture.h:23
osl::rating::Capture::name
static const std::string name(int first, int last)
Definition capture.cc:6
osl::rating::Capture::see
static int see(const NumEffectState &state, Move move, const RatingEnv &env)
Definition capture.h:24
osl::rating::Capture::INF
@ INF
Definition capture.h:18
osl::rating::Capture::first
int first
Definition capture.h:20
osl::rating::Capture::last
int last
Definition capture.h:20
osl::rating::ContinueCapture::ContinueCapture
ContinueCapture()
Definition capture.h:60
osl::rating::ContinueCapture::match
bool match(const NumEffectState &, Move move, const RatingEnv &env) const
Definition capture.h:61
osl::rating::DropCaptured::DropCaptured
DropCaptured(Ptype ptype)
Definition capture.cc:18
osl::rating::DropCaptured::ptype
Ptype ptype
Definition capture.h:71
osl::rating::DropCaptured::match
bool match(const NumEffectState &, Move move, const RatingEnv &env) const
Definition capture.h:74
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::RatingEnv
Definition ratingEnv.h:16
osl::rating::RatingEnv::history
MoveStack history
Definition ratingEnv.h:18
osl::rating::RatingEnv::op_pin
PieceMask op_pin
Definition ratingEnv.h:20
osl::rating::RatingEnv::my_pin
PieceMask my_pin
Definition ratingEnv.h:20
osl::rating::ShadowEffect1::ShadowEffect1
ShadowEffect1()
Definition capture.h:40
osl::rating::ShadowEffect1::match
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition capture.h:41
osl::rating::ShadowEffect2::ShadowEffect2
ShadowEffect2()
Definition capture.h:50
osl::rating::ShadowEffect2::match
bool match(const NumEffectState &state, Move move, const RatingEnv &) const
Definition capture.h:51
osl::rating
Definition construct.h:18
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition basic_type.h:85
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
feature.h
see.h
shadowEffect.h
osl::See::see
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
osl::ShadowEffect::count2
static int count2(const NumEffectState &, Square target, Player attack)
target に attack の影利きを二つまで数える.
Definition shadowEffect.cc:24