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
00009 void usage(const char *program_name)
00010 {
00011 }
00012
00013 using namespace osl;
00014
00015 void processRecord(osl::vector<Move> const& moves)
00016 {
00017 HashEffectState state((SimpleState(HIRATE)));
00018 RepetitionCounter counter(state);
00019 for (size_t i=0; i<moves.size (); ++i)
00020 {
00021 std::cout << i+1 << " " << record::csa::show(moves[i]) << std::endl;
00022 std::cout << counter.isSennichite(state, moves[i]) << std::endl;
00023 std::cout << "("
00024 << counter.isAlmostSennichite(state.getHash().newHashWithMove(moves[i]))
00025 << ")\n";
00026 ApplyMoveOfTurn::doMove(state, moves[i]);
00027 counter.push(state);
00028 const int times = counter.countRepetition(state.getHash());
00029 if (times > 1)
00030 {
00031 std::cout << times
00032 << "-times, first appeared at "
00033 << counter.getFirstMove(state.getHash())
00034 << " check " << counter.checkCount(BLACK)
00035 << " " << counter.checkCount(WHITE)
00036 << "\n";
00037 }
00038 std::cout << "\n";
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
00049
00050 extern int optind;
00051 char c;
00052 while ((c = getopt(argc, argv, "vh")) != EOF)
00053 {
00054 switch(c)
00055 {
00056 case 'v': verbose = true;
00057 break;
00058 default: error_flag = true;
00059 }
00060 }
00061 argc -= optind;
00062 argv += optind;
00063
00064 if (error_flag)
00065 usage(program_name);
00066
00067 nice(20);
00068
00069
00070 for (int i=0; i<argc; ++i)
00071 {
00072 CsaFile file(argv [i]);
00073 const vector<Move> moves=file.getRecord().getMoves();
00074
00075 processRecord(moves);
00076 }
00077 }
00078
00079
00080
00081
00082
00083