Go to the documentation of this file.00001
00002
00003 #include "osl/game_playing/gameState.h"
00004 #include "osl/record/kisen.h"
00005 #include "osl/record/csaRecord.h"
00006 #include "osl/container/moveVector.h"
00007 #include "osl/sennichite.h"
00008 #include <boost/program_options.hpp>
00009 #include <boost/foreach.hpp>
00010 #include <iostream>
00011 #include <cmath>
00012 namespace po = boost::program_options;
00013
00014 using namespace osl;
00015 int count = 0;
00016 bool run(const NumEffectState& initial, const vector<Move>& moves)
00017 {
00018 NumEffectState state(initial);
00019 for (size_t i=0; i<moves.size(); ++i){
00020 state.makeMove(moves[i]);
00021 Player P = alt(state.turn());
00022 if (state.kingSquare(P).squareForBlack(P).y() < 5) {
00023
00024 return true;
00025 }
00026 }
00027 return false;
00028 }
00029
00030
00031 int main(int argc, char **argv) {
00032 std::string kisen_filename;
00033 po::options_description options("Options");
00034 options.add_options()
00035 ("kisen,k",
00036 po::value<std::string>(&kisen_filename),
00037 "kisen filename")
00038 ("csa-file", po::value<std::vector<std::string> >())
00039 ("help", "produce help message")
00040 ;
00041 po::positional_options_description p;
00042 p.add("csa-file", -1);
00043
00044 po::variables_map vm;
00045 std::vector<std::string> filenames;
00046 try {
00047 po::store(po::command_line_parser(argc, argv).
00048 options(options).positional(p).run(), vm);
00049 notify(vm);
00050 if (vm.count("help")) {
00051 std::cout << options << std::endl;
00052 return 0;
00053 }
00054 if (vm.count("csa-file"))
00055 filenames = vm["csa-file"].as<std::vector<std::string> >();
00056 }
00057 catch (std::exception& e) {
00058 std::cerr << "error in parsing options" << std::endl
00059 << e.what() << std::endl;
00060 std::cerr << options << std::endl;
00061 return 1;
00062 }
00063
00064 if (kisen_filename != "") {
00065 KisenFile kisen(kisen_filename);
00066 for (size_t i=0; i<kisen.size(); ++i) {
00067 std::cerr << '.';
00068 NumEffectState state(kisen.getInitialState());
00069 vector<Move> moves = kisen.getMoves(i);
00070 if (run(state, moves))
00071 std::cout << i << "\n";
00072 }
00073 }
00074 for (size_t i=0; i<filenames.size(); ++i) {
00075 std::cerr << '.';
00076 CsaFile file(filenames[i].c_str());
00077 NumEffectState state(file.getInitialState());
00078 vector<Move> moves = file.getRecord().getMoves();
00079 if (run(state, moves))
00080 std::cout << filenames[i] << "\n";
00081 }
00082 std::cerr << "count = " << count << "\n";
00083 }
00084
00085
00086
00087
00088