All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sample/progress/progress.cc
Go to the documentation of this file.
5 #include "osl/record/kisen.h"
7 #include "osl/sennichite.h"
8 
9 #include <boost/program_options.hpp>
10 #include <iostream>
11 
12 namespace po = boost::program_options;
13 
14 int main(int argc, char **argv)
15 {
16  std::string kisen_filename;
17  int kisen_index;
18  po::options_description options("Options");
19  options.add_options()
20  ("kisen,k",
21  po::value<std::string>(&kisen_filename),
22  "kisen filename")
23  ("index,i",
24  po::value<int>(&kisen_index)->default_value(0))
25  ("help", "produce help message")
26  ;
27  po::positional_options_description p;
28  po::variables_map vm;
29 
30  try
31  {
32  po::store(po::command_line_parser(argc, argv).
33  options(options).positional(p).run(), vm);
34  notify(vm);
35  if (vm.count("help"))
36  {
37  std::cout << options << std::endl;
38  return 0;
39  }
40  }
41  catch (std::exception& e)
42  {
43  std::cerr << "error in parsing options" << std::endl
44  << e.what() << std::endl;
45  std::cerr << options << std::endl;
46  return 1;
47  }
48 
49  osl::record::KisenFile kisen(kisen_filename);
51  osl::stl::vector<osl::Move> moves = kisen.getMoves(kisen_index);
52 
54  osl::progress::ml::NewProgress progress(state);
55 
56  for (size_t i = 0; i < moves.size() + 1; ++i)
57  {
58  if (!state.inCheck())
59  {
60  // 16().value
61  std::cout << i << " " << progress.progress() << std::endl;
62  }
63  if (i < moves.size())
64  {
65  state.makeMove(moves[i]);
66  progress.update(state, moves[i]);
67  }
68  }
69 
70  return 0;
71 }