4 #include <boost/program_options.hpp> 
   39               bool save, 
const std::vector<std::string> &
files)
 
   43   for (
size_t index = 0; index < files.size(); index++)
 
   46     for (
size_t i = 0; i < kisen.
size(); i++)
 
   52       for (; j < moves.size() && (int)j < num_ply; j++)
 
   55           = state.kingSquare(
alt(state.turn()));
 
   56         if (state.hasEffectAt(state.turn(), opKingSquare))
 
   60         state.makeMove(moves[j]);
 
   62       if ((
int)j == num_ply)
 
   65         if (it != states.end())
 
   73           for (
int k = 0; k < num_ply; k++)
 
   75             s.
moves.push_back(moves[k]);
 
   88     if (it->second.count >= threshold)
 
   90       std::cout << index << 
" (" << it->second.
count << 
")" << std::endl;
 
   91       std::cout << it->first;
 
   96         oss << index << 
".csa";
 
   97         const std::string &filename = oss.str();
 
   98         output.open(filename.c_str());
 
   99         output << 
"PI" << std::endl
 
  103       for (
size_t i = 0; i < moves.size(); i++)
 
  115       std::cout << std::endl;
 
  121 int main(
int argc, 
char **argv)
 
  126   boost::program_options::options_description command_line_options;
 
  127   command_line_options.add_options()
 
  129      boost::program_options::value<int>(&num_ply)->default_value(10),
 
  130      "Show states after this number of plies are played")
 
  132      boost::program_options::value<int>(&threshold)->default_value(10),
 
  133      "Each state must appear this number of times to be shown")
 
  135      boost::program_options::value<bool>(&save_moves)->default_value(
false),
 
  136      "Save moves leading to states to files in CSA format")
 
  137     (
"input-file", boost::program_options::value< std::vector<std::string> >(),
 
  138      "input files in kisen format")
 
  139     (
"help", 
"Show help message");
 
  140   boost::program_options::variables_map 
vm;
 
  141   boost::program_options::positional_options_description p;
 
  142   p.add(
"input-file", -1);
 
  147       boost::program_options::command_line_parser(
 
  148         argc, argv).options(command_line_options).positional(p).
run(), vm);
 
  149     boost::program_options::notify(vm);
 
  150     if (vm.count(
"help"))
 
  152       std::cerr << 
"Usage: " << argv[0] << 
" [options] kisen-file" 
  154       std::cout << command_line_options << std::endl;
 
  158   catch (std::exception &e)
 
  160     std::cerr << 
"error in parsing options" << std::endl
 
  161               << e.what() << std::endl;
 
  162     std::cerr << 
"Usage: " << argv[0] << 
" [options] kisen-file" << std::endl;
 
  163     std::cerr << command_line_options << std::endl;
 
  167   const std::vector<std::string> 
files =
 
  168     vm[
"input-file"].as< std::vector<std::string> >();
 
  169   find_all(num_ply, threshold, save_moves, files);