7 #include <boost/program_options.hpp> 
    8 #include <boost/scoped_ptr.hpp> 
    9 #include <boost/foreach.hpp> 
   10 #include <boost/progress.hpp> 
   16 namespace po = boost::program_options;
 
   19 void run(
const std::string& filename);
 
   20 int main(
int argc, 
char **argv)
 
   22   po::options_description options(
"options");
 
   24     (
"help", 
"produce help message")
 
   26      po::value<size_t>(&
max_nodes)->default_value(80000),
 
   27      "search proof/disproof positions within this limit")
 
   29      po::value<size_t>(&
min_nodes)->default_value(8000),
 
   30      "ignore positions proven/disproven by search with less than this limit")
 
   33      "search proof/disproof problems")
 
   35      po::value<size_t>(&
filenumber)->default_value(1),
 
   36      "start number of filenames for generated problems")
 
   38   po::options_description hidden(
"Hidden options");
 
   40     (
"target-file", po::value<std::vector<std::string> >());
 
   41   po::options_description command_line_options;
 
   42   command_line_options.add(options).add(hidden);
 
   43   po::options_description visible_options(
"All options");
 
   44   visible_options.add(options);
 
   46   po::positional_options_description p;
 
   47   p.add(
"target-file", -1);
 
   50   std::vector<std::string> filenames;
 
   53     po::store(po::command_line_parser(argc, argv).
 
   54               options(command_line_options).positional(p).
run(), vm);
 
   56     if (vm.count(
"help")) {
 
   57       std::cerr << 
"Usage: " << argv[0] << 
" [options] files" << std::endl;
 
   58       std::cout << visible_options << std::endl;
 
   61     filenames = vm[
"target-file"].as<std::vector<std::string> >();
 
   63   catch (std::exception& e) {
 
   64     std::cerr << 
"error in parsing options" << std::endl
 
   65               << e.what() << std::endl;
 
   66     std::cerr << 
"Usage: " << argv[0] << 
" [options] files" << std::endl;
 
   67     std::cerr << visible_options << std::endl;
 
   70   boost::progress_display progress(filenames.size());
 
   71   BOOST_FOREACH(
const std::string& filename, filenames) {
 
   80   std::ostringstream ss;
 
   81   ss << std::setw(4) << std::setfill(
'0') << 
filenumber++ << 
".csa";
 
   82   std::ofstream os(ss.str().c_str());
 
   86   os << 
"' " << count << 
" nodes\n";
 
  104 void run(
const std::string& filename)
 
  106   CsaFile file(filename);
 
  107   const vector<Move> 
moves=file.getRecord().getMoves();
 
  108   NumEffectState state;
 
  111   BOOST_FOREACH(
Move move, moves) {
 
  112     state.makeMove(move);
 
  113     if (++moved < 50 || state.inCheck())
 
  116       MoveVector legal_moves;
 
  118       std::random_shuffle(legal_moves.begin(), legal_moves.end());
 
  119       BOOST_FOREACH(
Move a, legal_moves) {
 
  120         NumEffectState copy(state);