All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
show-progresseval.cc
Go to the documentation of this file.
1 /* show-progresseval.cc
2  */
5 #include "osl/record/csaRecord.h"
7 #include "osl/oslConfig.h"
8 #include <iostream>
9 #include <iomanip>
10 #include <cstdlib>
11 #include <cstdio>
12 #include <unistd.h>
13 
14 using namespace osl;
15 using namespace osl::eval;
16 
17 void usage(const char *prog)
18 {
19  using namespace std;
20  cerr << "Usage: " << prog << " csa-filename"
21  << endl;
22  exit(1);
23  }
24 
25 void show(const char *filename);
26 int verbose = 0;
27 int max_progress = 8;
28 
29 int main(int argc, char **argv)
30 {
31  const char *program_name = argv[0];
32  bool error_flag = false;
33 
34  // extern char *optarg;
35  extern int optind;
36  char c;
37  while ((c = getopt(argc, argv, "vh")) != EOF)
38  {
39  switch(c)
40  {
41  default: error_flag = true;
42  }
43  }
44  argc -= optind;
45  argv += optind;
46 
47  if (error_flag)
48  usage(program_name);
49 
51  eval::PiecePairPieceEval::setUp();
52 
53  for (int i=0; i<argc; ++i)
54  {
55  show(argv[i]);
56  }
57 }
58 
59 void show(const NumEffectState& state)
60 {
61  const progress::Effect5x3 progress(state);
62  if (progress.progress16().value() > max_progress)
63  return;
64  if (verbose)
65  std::cout << state;
66  const eval::ProgressEval eval(state);
67  const PieceEval piece(state);
68  const eval::PiecePairPieceEval ppair(state);
69 
70  if (verbose)
71  std::cout << "progress piece ppair endgame safety pieceadjust total\n";
72  std::cout << progress.progress16().value()
73  << " " << piece.value() << " " << ppair.value()
74  << " " << eval.endgameValue()
75  << " " << eval.attackDefenseBonus() << " " << eval.minorPieceValue()
76  << " " << eval.value() << "\n";
77 }
78 
79 void show(const char *filename)
80 {
81  CsaFile file(filename);
82  const vector<osl::Move> moves = file.getRecord().getMoves();
83  NumEffectState state(file.getInitialState());
84  for (unsigned int i=0; i<moves.size(); i++)
85  {
86  show(state);
87  const Move m = moves[i];
88  state.makeMove(m);
89  }
90  show(state);
91 }
92 
93 /* ------------------------------------------------------------------------- */
94 // ;;; Local Variables:
95 // ;;; mode:c++
96 // ;;; c-basic-offset:2
97 // ;;; End: