4 #include <boost/program_options.hpp>
5 #include <boost/format.hpp>
23 bool save,
const std::vector<std::string> &
files)
27 for (
size_t index = 0; index < files.size(); index++)
30 for (
size_t i = 0; i < kisen.
size(); i++)
36 for (
size_t j = 0; j < moves.size() && j < static_cast<size_t>(num_ply);
40 = state.kingSquare(
alt(state.turn()));
41 if (state.hasEffectAt(state.turn(), opKingSquare))
45 state.makeMove(moves[j]);
60 output.open((boost::format(
"%05d.csa") % index++).str().c_str());
71 int main(
int argc,
char **argv)
76 boost::program_options::options_description command_line_options;
77 command_line_options.add_options()
79 boost::program_options::value<int>(&num_ply)->default_value(10),
80 "Show states after this number of plies are played")
82 boost::program_options::value<int>(&threshold)->default_value(10),
83 "Each state must appear this number of times to be shown")
85 boost::program_options::value<bool>(&save_moves)->default_value(
false),
86 "Save moves leading to states to files in CSA format")
87 (
"input-file", boost::program_options::value< std::vector<std::string> >(),
88 "input files in kisen format")
89 (
"help",
"Show help message");
90 boost::program_options::variables_map
vm;
91 boost::program_options::positional_options_description p;
92 p.add(
"input-file", -1);
97 boost::program_options::command_line_parser(
98 argc, argv).options(command_line_options).positional(p).
run(), vm);
99 boost::program_options::notify(vm);
100 if (vm.count(
"help"))
102 std::cerr <<
"Usage: " << argv[0] <<
" [options] kisen-file"
104 std::cout << command_line_options << std::endl;
108 catch (std::exception &e)
110 std::cerr <<
"error in parsing options" << std::endl
111 << e.what() << std::endl;
112 std::cerr <<
"Usage: " << argv[0] <<
" [options] kisen-file" << std::endl;
113 std::cerr << command_line_options << std::endl;
117 const std::vector<std::string>
files =
118 vm[
"input-file"].as< std::vector<std::string> >();
119 find_all(num_ply, threshold, save_moves, files);