kakinoki-to-csa.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kakinoki-to-csa.cc
Go to the documentation of this file.
1 /* kakinoki-to-csa.cc
2 */
3 #include "osl/record/kakinoki.h"
4 #include "osl/record/ki2.h"
5 #include "osl/record/csa.h"
6 #include "osl/record/record.h"
7 #include <boost/algorithm/string/predicate.hpp>
8 #include <iostream>
9 #include <sstream>
10
11 using namespace osl;
12 void convert(const char *filename)
13 {
14 vector<Move> moves;
15 vector<int> time;
16 vector<std::string> comment;
17 vector<record::SearchInfo> move_comment;
18 Record record;
19 NumEffectState state;
20 if (boost::algorithm::iends_with(filename, ".ki2")) {
21 Ki2File file(filename);
22 record = file.getRecord();
23 state = file.getInitialState();
24 }
25 else {
26 KakinokiFile file(filename);
27 record = file.getRecord();
28 state = file.getInitialState();
29 }
30 std::cout << "N+" << record.getPlayer(BLACK) << std::endl;
31 std::cout << "N-" << record.getPlayer(WHITE) << std::endl;
32 record.getMoves(moves, time, comment, move_comment);
33 std::cout << state;
34 for (size_t i=0; i<moves.size(); ++i)
35 {
36 std::cout << record::csa::show(moves[i]) << std::endl;
37 if (i < comment.size())
38 {
39 std::istringstream is(comment[i]);
40 std::string line;
41 while (std::getline(is, line))
42 std::cout << "'* " << line << std::endl;
43 }
44 }
45 }
46
47 int main(int argc, char **argv)
48 {
49 for (int i=1; i<argc; ++i)
50 convert(argv[i]);
51 }
52
53 // ;;; Local Variables:
54 // ;;; mode:c++
55 // ;;; c-basic-offset:2
56 // ;;; End: