Go to the documentation of this file.00001
00002
00003
00004
00005 #include "osl/record/csaRecord.h"
00006 #include "osl/record/kisen.h"
00007 #include "osl/state/numEffectState.h"
00008 #include "osl/effect_util/effectUtil.h"
00009
00010 #include <iostream>
00011 #include <cstdlib>
00012 #include <unistd.h>
00013
00014 using namespace osl;
00015
00016 void usage(const char *prog)
00017 {
00018 using namespace std;
00019 cerr << "Usage: " << prog << " [-N atmost-N-games] [-k kisenFileName] csa-filenames "
00020 << endl;
00021
00022 exit(1);
00023 }
00024
00025 void processKifu (osl::vector<Move> const& moves)
00026 {
00027 NumEffectState state((SimpleState(HIRATE)));
00028 std::cout << state << std::endl;
00029 for (size_t i=0; i<moves.size (); ++i)
00030 {
00031 if (state.inCheck(alt(state.turn())))
00032 {
00033
00034 std::cerr << "e";
00035 break;
00036 }
00037 state.makeMove(moves[i]);
00038 std::cout << state << std::endl;
00039 }
00040 std::cout << state << std::endl;
00041 }
00042
00043 int main(int argc, char **argv)
00044 {
00045 const char *program_name = argv[0];
00046 bool error_flag = false;
00047 bool verbose = false;
00048 const char *kisenFilename = 0;
00049
00050 extern char *optarg;
00051 extern int optind;
00052 char c;
00053 size_t num_records = 1;
00054 while ((c = getopt(argc, argv, "N:k:vh")) != EOF)
00055 {
00056 switch(c)
00057 {
00058 case 'k': kisenFilename = optarg;
00059 break;
00060 case 'N': num_records = atoi(optarg);
00061 break;
00062 case 'v': verbose = true;
00063 break;
00064 default: error_flag = true;
00065 }
00066 }
00067 argc -= optind;
00068 argv += optind;
00069
00070 if (error_flag)
00071 usage(program_name);
00072
00073 try
00074 {
00075 nice(20);
00076 size_t record_processed = 0;
00077
00078
00079 if (kisenFilename)
00080 {
00081 KisenFile kisenFile(kisenFilename);
00082
00083 for (size_t i=0; i<kisenFile.size(); i++)
00084 {
00085 if (++record_processed > num_records)
00086 break;
00087 const vector<Move> moves=kisenFile.getMoves(i);
00088 processKifu (moves);
00089 }
00090 }
00091
00092
00093 for (int i=0; i<argc; ++i)
00094 {
00095 if (++record_processed > num_records)
00096 break;
00097 CsaFile file(argv [i]);
00098 const vector<Move> moves=file.getRecord().getMoves();
00099
00100 processKifu (moves);
00101 }
00102 }
00103
00104 catch (std::exception& e)
00105 {
00106 std::cerr << e.what() << "\n";
00107 return 1;
00108 }
00109 }
00110
00111
00112
00113
00114