12 #include <boost/algorithm/string/predicate.hpp>
16 namespace csa=osl::record::csa;
37 osl::vector<int> copy;
40 sort(copy.begin(), copy.end());
41 if (copy.size() == 1)
return 0;
42 if (copy.size()%2)
return copy[copy.size()/2];
43 return copy[copy.size()/2]-1;
46 std::vector<std::pair<int,Ptype> > gradient_ptype;
49 gradient_ptype.push_back(std::make_pair(
gradient[ptype], ptype));
52 gradient_ptype.push_back(std::make_pair(
gradient[ptype], ptype));
55 std::sort(gradient_ptype.begin(), gradient_ptype.end());
58 const int a[13] = { -3, -2, -2, -1, -1, -1, 0, 1, 1, 1, 2, 2, 3 };
59 for (
size_t i=0; i<gradient_ptype.size(); ++i)
60 weight[gradient_ptype[i].second] += a[i];
62 void count(
const NumEffectState& state, CArray<int,PTYPE_SIZE>&
out) {
65 Piece p = state.pieceOf(i);
70 const NumEffectState& not_selected) {
71 CArray<int,PTYPE_SIZE> c0, c1, diff;
73 count(not_selected, c1);
77 evaldiff += diff[i] *
weight[i];
79 if (evaldiff > 0)
return;
88 for (
size_t i=0; i<all.size(); ++i) {
89 if (! all[i].isCaptureOrPromotion())
continue;
90 int see = See::see(state, all[i]);
91 if (see <= best_see)
continue;
97 void make_PV(
const NumEffectState& src,
Move prev, MoveVector& pv) {
98 NumEffectState state(src);
102 state.makeMove(prev);
110 void make_moves(NumEffectState& state,
const MoveVector& pv) {
111 for (
size_t i=0; i<pv.size(); ++i)
112 state.makeMove(pv[i]);
116 NumEffectState state;
117 for (
size_t i=0; i<moves.size(); ++i) {
118 const Move selected = moves[i];
122 if (! state.hasEffectAt(
alt(selected.
player()), selected.
to())) {
125 NumEffectState s0(state);
127 for (
size_t j=0; j<all.size(); ++j)
128 if (all[j] != selected) {
131 NumEffectState s1(state);
136 state.makeMove(selected);
139 int main(
int argc,
char **argv) {
141 for (
int t=0; t<1024; ++t) {
144 for (
int i=1; i<argc; ++i) {
145 const char *filename = argv[i];
146 if (boost::algorithm::iends_with(filename,
".csa")) {
147 const CsaFile csa(filename);
148 run(csa.getRecord().getMoves());
150 else if (boost::algorithm::iends_with(filename,
".ki2")) {
151 const Ki2File ki2(filename);
152 run(ki2.getRecord().getMoves());
154 else if (boost::algorithm::iends_with(filename,
".kif")
155 && KakinokiFile::isKakinokiFile(filename)) {
156 const KakinokiFile kif(filename);
157 run(kif.getRecord().getMoves());
159 else if (boost::algorithm::iends_with(filename,
".kif")) {
160 KisenFile kisen(filename);
161 for (
size_t j=0; j<kisen.size(); ++j)
162 run(kisen.getMoves(j));
165 cerr <<
"Unknown file type: " << filename <<
"\n";