pinGroup.h
Go to the documentation of this file.
/* pinGroup.h
*/
#ifndef _PINGROUP_H
#define _PINGROUP_H
#include "osl/rating/group.h"
#include "osl/rating/feature/pinAttack.h"
namespace osl
{
namespace rating
{
struct PinGroup : public Group
{
PinGroup() : Group("PinAttack")
{
for (int s = PTYPE_PIECE_MIN; s<= PTYPE_MAX; ++s) {
for (int t = PTYPE_PIECE_MIN; t<= PTYPE_MAX; ++t) {
const Ptype self = static_cast<Ptype>(s);
const Ptype target = static_cast<Ptype>(t);
for (int p=0; p<8; ++p) // progress8
push_back(new PinAttack(true, self, target));
for (int p=0; p<8; ++p) // progress8
push_back(new PinAttack(false, self, target));
}
}
}
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 findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
{
const int progress8 = env.progress.value()/2;
const int attack_index = PinAttack::index(state, move, env, true);
if (attack_index >= 0)
return attack_index*8 + progress8;
const int defense_index = PinAttack::index(state, move, env, false);
if (defense_index >= 0)
return defense_index*8 + progress8;
return -1;
}
};
struct EscapePinGroup : public Group
{
EscapePinGroup() : Group("EscapePin")
{
for (int s = PTYPE_BASIC_MIN+1; s<= PTYPE_MAX; ++s) {
const Ptype self = static_cast<Ptype>(s);
for (int p=0; p<8; ++p) // progress8
push_back(new EscapePin(self));
}
}
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 findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
{
if (move.ptype() != KING || ! env.my_pin.any())
return -1;
int s;
for (s = PTYPE_BASIC_MIN+1; s<= PTYPE_MAX; ++s) {
const Ptype pinned = static_cast<Ptype>(s);
if ((env.my_pin.getMask(Ptype_Table.getIndex(pinned))
& Ptype_Table.getMaskLow(pinned)).any())
break;
}
s -= PTYPE_BASIC_MIN+1;
assert(s >= 0);
const int progress8 = env.progress.value()/2;
return s*8 + progress8;
}
};
}
}
#endif /* _PINGROUP_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::PieceMask::getMask
const mask_t getMask(int num) const
Definition pieceMask.h:59
osl::PieceMask::any
bool any() const
Definition pieceMask.h:57
osl::progress::ProgressN::value
int value() const
Definition progress.h:22
osl::rating::EscapePin
Definition pinAttack.h:75
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::PinAttack
Definition pinAttack.h:14
osl::rating::PinAttack::index
static int index(const NumEffectState &state, Move move, const RatingEnv &, bool attack, Piece p)
Definition pinAttack.h:45
osl::rating::RatingEnv
Definition ratingEnv.h:16
osl::rating::RatingEnv::progress
Progress16 progress
Definition ratingEnv.h:22
osl::rating::RatingEnv::my_pin
PieceMask my_pin
Definition ratingEnv.h:20
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
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::PTYPE_PIECE_MIN
@ PTYPE_PIECE_MIN
Definition basic_type.h:104
osl::PTYPE_MAX
@ PTYPE_MAX
Definition basic_type.h:105
osl::KING
@ KING
Definition basic_type.h:93
osl::PTYPE_BASIC_MIN
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition tables.cc:97
pinAttack.h
osl::rating::EscapePinGroup::show
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition pinGroup.h:56
osl::rating::EscapePinGroup::EscapePinGroup
EscapePinGroup()
Definition pinGroup.h:48
osl::rating::EscapePinGroup::findMatch
int findMatch(const NumEffectState &, Move move, const RatingEnv &env) const
Definition pinGroup.h:61
osl::rating::PinGroup::show
void show(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
Definition pinGroup.h:28
osl::rating::PinGroup::PinGroup
PinGroup()
Definition pinGroup.h:15
osl::rating::PinGroup::findMatch
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
Definition pinGroup.h:33