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