move_probability/featureSet.h
Go to the documentation of this file.
/* featureSet.h
*/
#ifndef OSL_MOVE_PROBABILITY_FEATURESET_H
#define OSL_MOVE_PROBABILITY_FEATURESET_H
#include "osl/move_probability/stateInfo.h"
#include "osl/numEffectState.h"
#include "osl/container/moveLogProbVector.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_array.hpp>
#include <vector>
namespace osl
{
namespace move_probability
{
class Feature;
typedef std::pair<double,Move> WeightedMove;
typedef FixedCapacityVector<WeightedMove,Move::MaxUniqMoves> WeightedMoveVector;
class FeatureSet
{
boost::ptr_vector<Feature> features;
std::vector<int> offsets, light_features;
protected:
FeatureSet();
public:
~FeatureSet();
void pushBack(Feature *, bool light=false);
void addFinished();
int dimension() const { return offsets.back(); }
public:
double matchExp(const StateInfo&, Move, const double *weights) const;
double matchNoExp(const StateInfo&, Move, const double *weights) const;
void generateLogProb(const StateInfo& state,
MoveLogProbVector& out, const double *weights) const;
double matchLight(const StateInfo&, Move, const double *weights) const;
bool load(const char *base_filename, double *weights) const;
bool load_binary(const char *base_filename, double *weights) const;
void showSummary(const double *weights) const;
void analyze(const StateInfo& state, Move move, const double *weights) const;
// for fine control
double generateRating(const StateInfo& state,
WeightedMoveVector& out, const double *weights) const;
static void ratingToLogProb(const WeightedMoveVector& rating,
double sum, MoveLogProbVector& out);
};
class StandardFeatureSet : public FeatureSet
{
static boost::scoped_array<double> weights, tactical_weights;
bool initialized;
public:
StandardFeatureSet();
~StandardFeatureSet();
static const StandardFeatureSet& instance(bool verbose=false);
static bool healthCheck();
void generateLogProb(const StateInfo& state, MoveLogProbVector& out) const;
void generateLogProb2(const StateInfo& state, MoveLogProbVector& out) const;
void generateLogProb(const StateInfo& state, int limit, MoveLogProbVector& out, bool in_pv) const;
int logProbTakeBack(const StateInfo& state, Move target) const;
int logProbSeePlus(const StateInfo& state, Move target) const;
double matchLight(const StateInfo&, Move) const;
double matchExp(const StateInfo&, Move) const;
double matchNoExp(const StateInfo&, Move) const;
bool setUp(bool verbose=false);
bool ok() const { return initialized; }
private:
int tacticalLogProb(int offset, double sum) const;
};
}
}
#endif /* OSL_MOVE_PROBABILITY_FEATURESET_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::FixedCapacityVector
Definition container.h:137
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::container::MoveLogProbVector
Definition moveLogProbVector.h:14
osl::move_probability::FeatureSet::generateRating
double generateRating(const StateInfo &state, WeightedMoveVector &out, const double *weights) const
Definition featureSet_.cc:103
osl::move_probability::FeatureSet::matchExp
double matchExp(const StateInfo &, Move, const double *weights) const
Definition featureSet_.cc:62
osl::move_probability::FeatureSet::matchNoExp
double matchNoExp(const StateInfo &, Move, const double *weights) const
Definition featureSet_.cc:50
osl::move_probability::FeatureSet::generateLogProb
void generateLogProb(const StateInfo &state, MoveLogProbVector &out, const double *weights) const
Definition featureSet_.cc:135
osl::move_probability::FeatureSet::load_binary
bool load_binary(const char *base_filename, double *weights) const
Definition featureSet_.cc:161
osl::move_probability::FeatureSet::dimension
int dimension() const
Definition move_probability/featureSet.h:31
osl::move_probability::FeatureSet::offsets
std::vector< int > offsets
Definition move_probability/featureSet.h:24
osl::move_probability::FeatureSet::matchLight
double matchLight(const StateInfo &, Move, const double *weights) const
Definition featureSet_.cc:68
osl::move_probability::FeatureSet::analyze
void analyze(const StateInfo &state, Move move, const double *weights) const
Definition featureSet_.cc:81
osl::move_probability::FeatureSet::load
bool load(const char *base_filename, double *weights) const
Definition featureSet_.cc:144
osl::move_probability::FeatureSet::showSummary
void showSummary(const double *weights) const
Definition featureSet_.cc:180
osl::move_probability::FeatureSet::features
boost::ptr_vector< Feature > features
Definition move_probability/featureSet.h:23
osl::move_probability::FeatureSet::ratingToLogProb
static void ratingToLogProb(const WeightedMoveVector &rating, double sum, MoveLogProbVector &out)
Definition featureSet_.cc:120
osl::move_probability::FeatureSet::light_features
std::vector< int > light_features
Definition move_probability/featureSet.h:24
osl::move_probability::FeatureSet::FeatureSet
FeatureSet()
Definition featureSet_.cc:23
osl::move_probability::FeatureSet::~FeatureSet
~FeatureSet()
Definition featureSet_.cc:28
osl::move_probability::FeatureSet::pushBack
void pushBack(Feature *, bool light=false)
Definition featureSet_.cc:33
osl::move_probability::FeatureSet::addFinished
void addFinished()
Definition featureSet_.cc:41
osl::move_probability::Feature
Definition move_probability/feature.h:17
osl::move_probability::StandardFeatureSet::tactical_weights
static boost::scoped_array< double > tactical_weights
Definition move_probability/featureSet.h:52
osl::move_probability::StandardFeatureSet::~StandardFeatureSet
~StandardFeatureSet()
Definition featureSet_.cc:272
osl::move_probability::StandardFeatureSet::generateLogProb
void generateLogProb(const StateInfo &state, MoveLogProbVector &out) const
Definition featureSet_.cc:331
osl::move_probability::StandardFeatureSet::weights
static boost::scoped_array< double > weights
Definition move_probability/featureSet.h:52
osl::move_probability::StandardFeatureSet::StandardFeatureSet
StandardFeatureSet()
Definition featureSet_.cc:217
osl::move_probability::StandardFeatureSet::setUp
bool setUp(bool verbose=false)
Definition featureSet_.cc:299
osl::move_probability::StandardFeatureSet::logProbTakeBack
int logProbTakeBack(const StateInfo &state, Move target) const
Definition featureSet_.cc:389
osl::move_probability::StandardFeatureSet::generateLogProb2
void generateLogProb2(const StateInfo &state, MoveLogProbVector &out) const
Definition featureSet_.cc:337
osl::move_probability::StandardFeatureSet::initialized
bool initialized
Definition move_probability/featureSet.h:53
osl::move_probability::StandardFeatureSet::ok
bool ok() const
Definition move_probability/featureSet.h:69
osl::move_probability::StandardFeatureSet::logProbSeePlus
int logProbSeePlus(const StateInfo &state, Move target) const
Definition featureSet_.cc:397
osl::move_probability::StandardFeatureSet::healthCheck
static bool healthCheck()
Definition featureSet_.cc:286
osl::move_probability::StandardFeatureSet::instance
static const StandardFeatureSet & instance(bool verbose=false)
Definition featureSet_.cc:278
osl::move_probability::StandardFeatureSet::matchLight
double matchLight(const StateInfo &, Move) const
Definition featureSet_.cc:371
osl::move_probability::StandardFeatureSet::matchExp
double matchExp(const StateInfo &, Move) const
Definition featureSet_.cc:377
osl::move_probability::StandardFeatureSet::tacticalLogProb
int tacticalLogProb(int offset, double sum) const
Definition featureSet_.cc:405
osl::move_probability::StandardFeatureSet::matchNoExp
double matchNoExp(const StateInfo &, Move) const
Definition featureSet_.cc:383
moveLogProbVector.h
osl::move_probability
Definition move_probability/feature.h:15
osl::move_probability::WeightedMove
std::pair< double, Move > WeightedMove
Definition move_probability/featureSet.h:18
osl::move_probability::WeightedMoveVector
FixedCapacityVector< WeightedMove, Move::MaxUniqMoves > WeightedMoveVector
Definition move_probability/featureSet.h:19
osl::rating
Definition construct.h:18
osl
Definition additionalEffect.h:6
numEffectState.h
stateInfo.h
osl::move_probability::StateInfo
Definition stateInfo.h:21