14 #include <boost/program_options.hpp> 
   18 using namespace osl::rating;
 
   19 namespace po = boost::program_options;
 
   23 void run(NumEffectState& state, 
const vector<Move>& 
moves);
 
   26 int main(
int argc, 
char **argv)
 
   29   std::vector<std::string> filenames;
 
   30   po::options_description options(
"Options");
 
   33      po::value<std::vector<std::string> >(),
 
   39      po::value<size_t>(&
num_kisen)->default_value(0),
 
   40      "number of records in kisen to be processed")
 
   43      "ignore moves whose log-probability is greater than this threshold")
 
   46      "number of opening moves ignored in analysis");
 
   48   po::positional_options_description p;
 
   49   p.add(
"csa-file", -1);
 
   52     po::store(po::command_line_parser(argc, argv).
 
   53               options(options).positional(p).
run(), vm);
 
   55     if (vm.count(
"help")) {
 
   56       std::cout << options << std::endl;
 
   59     if (vm.count(
"csa-file"))
 
   60       filenames = vm[
"csa-file"].as<std::vector<std::string> >();
 
   62   catch (std::exception& e)
 
   64     std::cerr << 
"error in parsing options" << std::endl
 
   65               << e.what() << std::endl;
 
   66     std::cerr << options << std::endl;
 
   69   if (kisen_filename != 
"") {
 
   70     std::cerr << 
"kisen " << kisen_filename << 
"\n";
 
   71     KisenFile kisen_file(kisen_filename.c_str());
 
   77       NumEffectState state(kisen_file.getInitialState());
 
   78       const osl::vector<Move> 
moves = kisen_file.getMoves(i);
 
   82   for (
size_t i=0; i<filenames.size(); ++i) {
 
   85     CsaFile file(filenames[i]);
 
   86     NumEffectState state(file.getInitialState());
 
   87     const osl::vector<Move> 
moves = file.getRecord().getMoves();
 
   96 void show(
const NumEffectState& state, 
Move next)
 
   99   MoveLogProbVector 
moves;
 
  107   int index = rm - &*moves.begin();
 
  108   for (
size_t i=0; i<
top_rated.size(); ++i) {
 
  109     if (i >= moves.size())
 
  115     bool found = index == (int)i;
 
  120 void run(NumEffectState& state, 
const vector<Move>& 
moves)
 
  122   for (
size_t i=0; i<moves.size(); ++i) {
 
  123     if (state.inCheck(
alt(state.turn())))
 
  126     const Move move = moves[i];
 
  129     state.makeMove(move);
 
  135   for (
size_t i=0; i<
top_rated.size(); ++i)
 
  136     std::cout << 
"top " << i 
 
  137               << 
" " << 
top_rated[i].getAverage()*100.0 
 
  138               << 
" " << 
active[i].getAverage()*100.0