File: progress.cc

package info (click to toggle)
libosl 0.8.0-4.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,328 kB
  • sloc: cpp: 114,345; ruby: 1,290; ansic: 915; makefile: 431; perl: 309; sh: 35
file content (71 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "osl/eval/openMidEndingEval.h"
#include "osl/progress.h"
#include "osl/game_playing/alphaBetaPlayer.h"
#include "osl/game_playing/gameState.h"
#include "osl/record/kisen.h"
#include "osl/search/moveWithComment.h"
#include "osl/sennichite.h"

#include <boost/program_options.hpp>
#include <iostream>

namespace po = boost::program_options;

int main(int argc, char **argv)
{
  std::string kisen_filename;
  int kisen_index;
  po::options_description options("Options");
  options.add_options()
    ("kisen,k", 
     po::value<std::string>(&kisen_filename),
     "kisen filename")
    ("index,i",
     po::value<int>(&kisen_index)->default_value(0))
    ("help", "produce help message")
    ;
  po::positional_options_description p;
  po::variables_map vm;

  try
  {
    po::store(po::command_line_parser(argc, argv).
	      options(options).positional(p).run(), vm);
    notify(vm);
    if (vm.count("help"))
    {
      std::cout << options << std::endl;
      return 0;
    }
  }
  catch (std::exception& e)
  {
    std::cerr << "error in parsing options" << std::endl
	      << e.what() << std::endl;
    std::cerr << options << std::endl;
    return 1;
  }

  osl::record::KisenFile kisen(kisen_filename);
  osl::NumEffectState state(kisen.initialState());
  std::vector<osl::Move> moves = kisen.moves(kisen_index);

  osl::progress::ml::NewProgress::setUp();
  osl::progress::ml::NewProgress progress(state);

  for (size_t i = 0; i < moves.size() + 1; ++i)
  {
    if (!state.inCheck())
    {
      // 16().value
      std::cout << i << " " << progress.progress() << std::endl;
    }
    if (i < moves.size())
    {
      state.makeMove(moves[i]);
      progress.update(state, moves[i]);
    }
  }

  return 0;
}