Go to the documentation of this file.00001 #include "osl/state/numEffectState.h"
00002 #include "osl/record/kisen.h"
00003 #include "osl/record/csaIOError.h"
00004
00005 #include <boost/scoped_ptr.hpp>
00006 #include <iostream>
00007
00008 void usage (const char *program_name)
00009 {
00010 std::cerr << "Usage: " << program_name << " KISEN-FILE [out]"
00011 << std::endl;
00012 exit(1);
00013 }
00014
00015 void check_all(const char*filename, const char *output)
00016 {
00017 osl::record::KisenFile kisen(filename);
00018 boost::scoped_ptr<std::ofstream> os;
00019 boost::scoped_ptr<osl::record::OKisenStream> out;
00020 if (output) {
00021 os.reset(new std::ofstream(output));
00022 out.reset(new osl::record::OKisenStream(*os));
00023 }
00024
00025 for (size_t i = 0; i < kisen.size(); i++)
00026 {
00027 std::cout << i;
00028 if ((i % 16) == 15 || i + 1 == kisen.size())
00029 std::cout << std::endl;
00030 else
00031 std::cout << ' ';
00032 osl::state::NumEffectState state(kisen.getInitialState());
00033 osl::vector<osl::Move> moves;
00034 size_t j = 0;
00035 try {
00036 moves = kisen.getMoves(i);
00037 for (; j < moves.size(); j++)
00038 {
00039 const osl::Square opKingSquare
00040 = state.kingSquare(alt(state.turn()));
00041 if (state.hasEffectAt(state.turn(), opKingSquare))
00042 {
00043 if (j)
00044 --j;
00045 break;
00046 }
00047 state.makeMove(moves[j]);
00048 }
00049 moves.resize(j);
00050 }
00051 catch (osl::record::csa::CsaIOError& e) {
00052 std::cerr << e.what();
00053 }
00054
00055 if (out)
00056 out->save(kisen.getInitialState(), moves);
00057 }
00058 }
00059
00060 int main(int argc, char **argv)
00061 {
00062 if (! (argc == 2 || argc == 3))
00063 usage(argv[0]);
00064
00065 check_all(argv[1], (argc == 3) ? argv[2] : "");
00066
00067 return 0;
00068 }
00069
00070
00071
00072