8 #include <boost/program_options.hpp>
9 #include <boost/foreach.hpp>
12 namespace po = boost::program_options;
16 bool run(
const NumEffectState& initial,
const vector<Move>&
moves)
18 NumEffectState state(initial);
19 for (
size_t i=0; i<moves.size(); ++i){
20 state.makeMove(moves[i]);
22 if (state.kingSquare(P).squareForBlack(P).y() < 5) {
31 int main(
int argc,
char **argv) {
33 po::options_description options(
"Options");
38 (
"csa-file", po::value<std::vector<std::string> >())
39 (
"help",
"produce help message")
41 po::positional_options_description p;
42 p.add(
"csa-file", -1);
45 std::vector<std::string> filenames;
47 po::store(po::command_line_parser(argc, argv).
48 options(options).positional(p).
run(), vm);
50 if (vm.count(
"help")) {
51 std::cout << options << std::endl;
54 if (vm.count(
"csa-file"))
55 filenames = vm[
"csa-file"].as<std::vector<std::string> >();
57 catch (std::exception& e) {
58 std::cerr <<
"error in parsing options" << std::endl
59 << e.what() << std::endl;
60 std::cerr << options << std::endl;
64 if (kisen_filename !=
"") {
65 KisenFile kisen(kisen_filename);
66 for (
size_t i=0; i<kisen.size(); ++i) {
68 NumEffectState state(kisen.getInitialState());
69 vector<Move>
moves = kisen.getMoves(i);
70 if (
run(state, moves))
71 std::cout << i <<
"\n";
74 for (
size_t i=0; i<filenames.size(); ++i) {
76 CsaFile file(filenames[i].c_str());
77 NumEffectState state(file.getInitialState());
78 vector<Move>
moves = file.getRecord().getMoves();
79 if (
run(state, moves))
80 std::cout << filenames[i] <<
"\n";
82 std::cerr <<
"count = " <<
count <<
"\n";