All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ptypeProgress.h
Go to the documentation of this file.
1 /* ptpeProgress.h
2  */
3 #ifndef PROGRESS_PTYPE_PROGRESS_H
4 #define PROGRESS_PTYPE_PROGRESS_H
5 
6 #include "osl/ptype.h"
8 #include "osl/misc/carray.h"
9 #include <iosfwd>
10 namespace osl
11 {
12  namespace progress
13  {
17  {
18  private:
19  CArray<int,PTYPE_SIZE> ptype2Val;
20  CArray2d<int,PTYPEO_SIZE,Square::SIZE> pos2Val;
21  static const CArray<int,10> yVals;
22  public:
25  int progress(PtypeO ptypeo,Square pos) const{
26  return pos2Val[ptypeo-PTYPEO_MIN][pos.index()];
27  }
28  };
29  extern const PtypeProgressTable Ptype_Progress_Table;
30 
32  {
33  int val;
34  public:
35  explicit PtypeProgress(SimpleState const& state);
36  int progress() const{ return val; }
37  private:
38  void addVal(int d) { val+=d; }
39  public:
40  void changeTurn() {}
41  static int getProgress(const SimpleState& state)
42  {
43  const PtypeProgress progress(state);
44  return progress.progress();
45  }
46  void update(const SimpleState& , Move last_move)
47  {
48  const PtypeO ptypeo = last_move.ptypeO();
49  if (last_move.isDrop()) {
50  val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
52  return;
53  }
54  val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
55  - Ptype_Progress_Table.progress(ptypeo,last_move.from());
56  Ptype ptype = last_move.capturePtype();
57  if (ptype != PTYPE_EMPTY)
59  - Ptype_Progress_Table.progress(last_move.capturePtypeO(), last_move.to());
60  }
61 
62  bool operator==(const PtypeProgress rhs) const { return val == rhs.val; }
63  };
64  std::ostream& operator<<(std::ostream& os, PtypeProgress prog);
65  } // namespace progress
66  using progress::PtypeProgress;
67 } // namespace osl
68 
69 
70 #endif /* PROGRESS_PTYPE_PROGRESS_H */
71 // ;;; Local Variables:
72 // ;;; mode:c++
73 // ;;; c-basic-offset:2
74 // ;;; coding:utf-8
75 // ;;; End: