captureGroup.h
Go to the documentation of this file.
/* captureGroup.h
*/
#ifndef _CAPTUREGROUP_H
#define _CAPTUREGROUP_H
#include "osl/rating/group.h"
#include "osl/rating/feature/capture.h"
namespace osl
{
namespace rating
{
class CaptureGroup : public Group
{
public:
std::vector<int> see_range;
CaptureGroup();
void show(std::ostream& os, int name_width, const range_t& range,
const std::vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
{
const int progress8 = env.progress.value()/2;
const int see = Capture::see(state, move, env);
size_t index;
if (see > 50)
index = std::min(12, 7 + (see - 51) / 200);
else if (see < -50)
index = std::max(0, (see + 1250) / 200);
else
index = 6;
#ifndef NDEBUG
for (size_t i=0; i<see_range.size()-1; ++i) {
if (see < see_range[i+1]) {
assert(i == index);
return i*8+progress8;
}
}
assert(0);
abort();
#endif
return index*8+progress8;
}
bool effectiveInCheck() const { return true; }
};
struct ShadowEffectGroup : public Group
{
ShadowEffectGroup() : Group("ShadowEffect")
{
push_back(new ShadowEffect1());
push_back(new ShadowEffect2());
}
void show(std::ostream& os, int name_width, const range_t& range,
const std::vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv&) const
{
return ShadowEffect::count2(state, move.to(), move.player()) -1;
}
};
struct ContinueCaptureGroup : public Group
{
ContinueCaptureGroup() : Group("Cont.Capture")
{
for (int p=0; p<8; ++p) // progress8
push_back(new ContinueCapture());
}
void show(std::ostream& os, int name_width, const range_t& range,
const std::vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
{
if (! (*this)[0].match(state, move, env))
return -1;
const int progress8 = env.progress.value()/2;
return progress8;
}
};
struct DropCapturedGroup : public Group
{
DropCapturedGroup();
void show(std::ostream& os, int name_width, const range_t& range,
const std::vector<double>& weights) const
{
showTopN(os, name_width, range, weights, 3);
}
int findMatchWithoutProgress(Move move, const RatingEnv& env) const
{
if (! (move.isDrop() && env.history.hasLastMove(2)))
return -1;
const Move last2_move = env.history.lastMove(2);
if (! (last2_move.isNormal()
&& last2_move.capturePtype() != PTYPE_EMPTY
&& unpromote(last2_move.capturePtype()) == move.ptype()))
return -1;
return move.ptype() - PTYPE_BASIC_MIN;
}
int findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
{
const int index = findMatchWithoutProgress(move, env);
if (index < 0)
return index;
const int progress8 = env.progress.value()/2;
return index*8 + progress8;
}
};
}
}
#endif /* _CAPTUREGROUP_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
capture.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::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::progress::ProgressN::value
int value() const
Definition progress.h:22
osl::rating::CaptureGroup::CaptureGroup
CaptureGroup()
Definition captureGroup.cc:5
osl::rating::CaptureGroup::findMatch
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition captureGroup.h:23
osl::rating::CaptureGroup::effectiveInCheck
bool effectiveInCheck() const
Definition captureGroup.h:46
osl::rating::CaptureGroup::see_range
std::vector< int > see_range
Definition captureGroup.h:16
osl::rating::CaptureGroup::show
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition captureGroup.h:18
osl::rating::Capture::see
static int see(const NumEffectState &state, Move move, const RatingEnv &env)
Definition capture.h:24
osl::rating::ContinueCapture
Definition capture.h:58
osl::rating::Group::showAll
void showAll(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition group.cc:74
osl::rating::Group::showTopN
void showTopN(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights, int n) const
Definition group.cc:100
osl::rating::Group::Group
Group(const std::string &name)
Definition group.cc:15
osl::rating::RatingEnv
Definition ratingEnv.h:16
osl::rating::RatingEnv::history
MoveStack history
Definition ratingEnv.h:18
osl::rating::RatingEnv::progress
Progress16 progress
Definition ratingEnv.h:22
osl::rating::ShadowEffect1
Definition capture.h:38
osl::rating::ShadowEffect2
Definition capture.h:48
group.h
osl::rating
Definition construct.h:18
osl::rating::range_t
std::pair< int, int > range_t
Definition range.h:10
osl
Definition additionalEffect.h:6
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition basic_type.h:85
osl::PTYPE_BASIC_MIN
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
osl::ShadowEffect::count2
static int count2(const NumEffectState &, Square target, Player attack)
target に attack の影利きを二つまで数える.
Definition shadowEffect.cc:24
osl::rating::ContinueCaptureGroup::findMatch
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition captureGroup.h:79
osl::rating::ContinueCaptureGroup::ContinueCaptureGroup
ContinueCaptureGroup()
Definition captureGroup.h:69
osl::rating::ContinueCaptureGroup::show
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition captureGroup.h:74
osl::rating::DropCapturedGroup::findMatchWithoutProgress
int findMatchWithoutProgress(Move move, const RatingEnv &env) const
Definition captureGroup.h:96
osl::rating::DropCapturedGroup::DropCapturedGroup
DropCapturedGroup()
Definition captureGroup.cc:26
osl::rating::DropCapturedGroup::show
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition captureGroup.h:91
osl::rating::DropCapturedGroup::findMatch
int findMatch(const NumEffectState &, Move move, const RatingEnv &env) const
Definition captureGroup.h:107
osl::rating::ShadowEffectGroup::findMatch
int findMatch(const NumEffectState &state, Move move, const RatingEnv &) const
Definition captureGroup.h:61
osl::rating::ShadowEffectGroup::ShadowEffectGroup
ShadowEffectGroup()
Definition captureGroup.h:51
osl::rating::ShadowEffectGroup::show
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition captureGroup.h:56