6#include <boost/filesystem/path.hpp>
7#include <boost/filesystem/operations.hpp>
26 for (
size_t j=0; j<size(); ++j) {
27 if ((*
this)[j].match(state, m, env))
34 const std::vector<double>& weights)
const
37 boost::filesystem::path dir(directory);
38 boost::filesystem::create_directory(dir);
41 std::string filename = directory +
"/" + group_name +
".txt";
42 std::ofstream os(filename.c_str());
43 for (
int i=range.first; i<range.second; ++i)
44 os << std::setprecision(8) << weights[i] <<
"\n";
48 std::vector<double>& weights)
const
50 std::string filename = directory +
"/" + group_name +
".txt";
51 FILE *fp = fopen(filename.c_str(),
"r");
54 for (
int i=range.first; i<range.second; ++i) {
55 if (fscanf(fp,
"%lf", &weights[i]) != 1)
63 const std::vector<double>& weights)
const
66 for (
size_t f=0; f<size(); ++f) {
67 os << std::setw(name_width)
69 <<
" " << 400*log10(weights[f+range.first]) <<
"\n";
75 const std::vector<double>& weights)
const
78 showMinMax(os, name_width, range, weights);
79 for (
size_t i=0; i<size(); ++i) {
80 os <<
" " << (*this)[i].name() <<
" " << 400*log10(weights[i+range.first]);
86 const std::vector<double>& weights)
const
89 double min = 10000000000.0, max = -min;
90 for (
size_t i=0; i<size(); ++i) {
91 min = std::min(min, 400*log10(weights[i+range.first]));
92 max = std::max(max, 400*log10(weights[i+range.first]));
94 os << std::setw(name_width)
96 <<
" [" << min <<
" -- " << max <<
"] ";
101 const std::vector<double>& weights,
int n)
const
104 if ((
int)weights.size() <= n*2)
105 return showAll(os, name_width, range, weights);
106 showMinMax(os, name_width, range, weights);
107 std::vector<double> w;
109 for (
int i=range.first; i<range.second; ++i)
110 w.push_back(weights[i]);
111 std::sort(w.begin(), w.end());
112 for (
int i=0; i<n; ++i) {
113 double value = w[size()-1-i];
115 for (; j<range.second; ++j)
116 if (weights[j] == value)
118 os <<
" " << (*this)[j-range.first].name() <<
" " << 400*log10(value);
121 for (
int i=0; i<n; ++i) {
122 double value = w[n-1-i];
124 for (; j<range.second; ++j)
125 if (weights[j] == value)
127 os <<
" " << (*this)[j-range.first].name() <<
" " << 400*log10(value);
136 for (
int o=0; o<4; ++o) {
179 assert((*
this)[index].match(state, move, env));
185 push_back(
new Karanari(
false,
true));
186 push_back(
new Karanari(
false,
false));
187 push_back(
new Karanari(
true,
true));
188 push_back(
new Karanari(
true,
false));
199 :
Group(
"ImmediateAddSupport")
203 for (
int p=0; p<8; ++p)
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Ptype capturePtype() const
bool isNormal() const
INVALID でも PASS でもない.
const Square from() const
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
bool hasEffectIf(PtypeO ptypeo, Square attacker, Square target) const
attackerにptypeoの駒がいると仮定した場合にtargetに利きがあるかどうか を stateをupdateしないで確かめる.
const Move lastMove(size_t last=1) const
mutually exclusive set of features
void showAll(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
void saveResult(const std::string &directory, const range_t &range, const std::vector< double > &weights) const
virtual int findMatch(const NumEffectState &state, Move m, const RatingEnv &env) const
bool load(const std::string &directory, const range_t &range, std::vector< double > &weights) const
void showTopN(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights, int n) const
void showMinMax(std::ostream &os, int name_width, const range_t &range, const std::vector< double > &weights) const
virtual void show(std::ostream &, int name_width, const range_t &range, const std::vector< double > &weights) const
Group(const std::string &name)
static int index(const NumEffectState &state, Move move)
std::pair< int, int > range_t
bool isBasic(Ptype ptype)
ptypeが基本型(promoteしていない)かのチェック
int findMatch(const NumEffectState &state, Move move, const RatingEnv &env) const
int findMatch(const NumEffectState &state, Move move, const RatingEnv &) const