00001
00002
00003 #include "osl/repetitionCounter.h"
00004 #include "osl/apply_move/applyMove.h"
00005 #include "osl/record/csaRecord.h"
00006 #include "osl/record/csa.h"
00007 #include <iostream>
00008 #include <cstdio>
00009
00010 void usage(const char *program_name)
00011 {
00012 }
00013
00014 using namespace osl;
00015
00016 void processRecord(osl::vector<Move> const& moves)
00017 {
00018 NumEffectState state((SimpleState(HIRATE)));
00019 RepetitionCounter counter(state);
00020 for (size_t i=0; i<moves.size (); ++i)
00021 {
00022 std::cout << i+1 << " " << record::csa::show(moves[i]) << std::endl;
00023 std::cout << counter.isSennichite(state, moves[i]) << std::endl;
00024 std::cout << "("
00025 << counter.isAlmostSennichite(HashKey(state).newHashWithMove(moves[i]))
00026 << ")\n";
00027 ApplyMoveOfTurn::doMove(state, moves[i]);
00028 counter.push(state);
00029 const int times = counter.countRepetition(HashKey(state));
00030 if (times > 1)
00031 {
00032 std::cout << times
00033 << "-times, first appeared at "
00034 << counter.getFirstMove(HashKey(state))
00035 << " check " << counter.checkCount(BLACK)
00036 << " " << counter.checkCount(WHITE)
00037 << "\n";
00038 }
00039 std::cout << "\n";
00040 }
00041 std::cout << state << std::endl;
00042 }
00043
00044 int main(int argc, char **argv)
00045 {
00046 const char *program_name = argv[0];
00047 bool error_flag = false;
00048 bool verbose = false;
00049
00050
00051 extern int optind;
00052 char c;
00053 while ((c = getopt(argc, argv, "vh")) != EOF)
00054 {
00055 switch(c)
00056 {
00057 case 'v': verbose = true;
00058 break;
00059 default: error_flag = true;
00060 }
00061 }
00062 argc -= optind;
00063 argv += optind;
00064
00065 if (error_flag)
00066 usage(program_name);
00067
00068 nice(20);
00069
00070
00071 for (int i=0; i<argc; ++i)
00072 {
00073 CsaFile file(argv [i]);
00074 const vector<Move> moves=file.getRecord().getMoves();
00075
00076 processRecord(moves);
00077 }
00078 }
00079
00080
00081
00082
00083
00084