All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
show-sibling.cc
Go to the documentation of this file.
1 /* show-sibling.cc
2  */
6 #include "osl/record/csaRecord.h"
7 #include "osl/record/ki2.h"
8 #include "osl/record/kakinoki.h"
9 #include "osl/record/kisen.h"
10 #include <boost/algorithm/string/predicate.hpp>
11 #include <iostream>
12 using namespace osl;
13 using namespace std;
14 namespace csa=osl::record::csa;
15 void run(const osl::vector<Move>& moves) {
16  NumEffectState state;
17  for (size_t i=0; i<moves.size(); ++i) {
18  const Move selected = moves[i];
19  MoveVector all;
20  LegalMoves::generate(state, all);
21 
22  cout << "selected " << csa::show(selected) << " others";
23  for (size_t j=0; j<all.size(); ++j) {
24  if (all[j] != selected)
25  cout << " " << csa::show(all[j]);
26  }
27  cout << endl;
28 
29  state.makeMove(selected);
30  }
31 }
32 int main(int argc, char **argv) {
33  for (int i=1; i<argc; ++i) {
34  const char *filename = argv[i];
35  if (boost::algorithm::iends_with(filename, ".csa")) {
36  const CsaFile csa(filename);
37  run(csa.getRecord().getMoves());
38  }
39  else if (boost::algorithm::iends_with(filename, ".ki2")) {
40  const Ki2File ki2(filename);
41  run(ki2.getRecord().getMoves());
42  }
43  else if (boost::algorithm::iends_with(filename, ".kif")
44  && KakinokiFile::isKakinokiFile(filename)) {
45  const KakinokiFile kif(filename);
46  run(kif.getRecord().getMoves());
47  }
48  else if (boost::algorithm::iends_with(filename, ".kif")) {
49  KisenFile kisen(filename);
50  for (size_t j=0; j<kisen.size(); ++j)
51  run(kisen.getMoves(j));
52  }
53  else {
54  cerr << "Unknown file type: " << filename << "\n";
55  continue;
56  }
57  }
58 }
59 // ;;; Local Variables:
60 // ;;; mode:c++
61 // ;;; c-basic-offset:2
62 // ;;; coding:utf-8
63 // ;;; End: