My Project
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/numEffectState.h"
7 #include <iosfwd>
8 namespace osl
9 {
10  namespace progress
11  {
15  {
16  private:
19  static const CArray<int,10> yVals;
20  public:
21  void init();
23  int progress(PtypeO ptypeo,Square pos) const{
24  return pos2Val[ptypeo-PTYPEO_MIN][pos.index()];
25  }
26  };
27  extern PtypeProgressTable Ptype_Progress_Table;
28 
30  {
31  int val;
32  public:
33  explicit PtypeProgress(SimpleState const& state);
34  int progress() const{ return val; }
35  private:
36  void addVal(int d) { val+=d; }
37  public:
38  void changeTurn() {}
39  static int getProgress(const SimpleState& state)
40  {
41  const PtypeProgress progress(state);
42  return progress.progress();
43  }
44  void update(const SimpleState& , Move last_move)
45  {
46  const PtypeO ptypeo = last_move.ptypeO();
47  if (last_move.isDrop()) {
48  val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
50  return;
51  }
52  val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
53  - Ptype_Progress_Table.progress(ptypeo,last_move.from());
54  Ptype ptype = last_move.capturePtype();
55  if (ptype != PTYPE_EMPTY)
57  - Ptype_Progress_Table.progress(last_move.capturePtypeO(), last_move.to());
58  }
59 
60  bool operator==(const PtypeProgress rhs) const { return val == rhs.val; }
61  };
62  std::ostream& operator<<(std::ostream& os, PtypeProgress prog);
63  } // namespace progress
64  using progress::PtypeProgress;
65 } // namespace osl
66 
67 
68 #endif /* PROGRESS_PTYPE_PROGRESS_H */
69 // ;;; Local Variables:
70 // ;;; mode:c++
71 // ;;; c-basic-offset:2
72 // ;;; coding:utf-8
73 // ;;; End:
圧縮していない moveの表現 .
Definition: basic_type.h:1052
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Definition: basic_type.h:1162
bool isDrop() const
Definition: basic_type.h:1150
Ptype capturePtype() const
Definition: basic_type.h:1180
PtypeO capturePtypeO() const
Definition: basic_type.h:1185
const Square to() const
Definition: basic_type.h:1132
const Square from() const
Definition: basic_type.h:1125
unsigned int index() const
Definition: basic_type.h:572
static const Square STAND()
Definition: basic_type.h:548
ゲームの進行度を駒が自陣からどの程度前に進んでいるかの和で表現
Definition: ptypeProgress.h:15
static const CArray< int, 10 > yVals
y 座標に対応した進行度の係数、最初は0 (使用しない)
Definition: ptypeProgress.h:19
int progress(PtypeO ptypeo, Square pos) const
Definition: ptypeProgress.h:23
CArray2d< int, PTYPEO_SIZE, Square::SIZE > pos2Val
Definition: ptypeProgress.h:18
CArray< int, PTYPE_SIZE > ptype2Val
Definition: ptypeProgress.h:17
void update(const SimpleState &, Move last_move)
Definition: ptypeProgress.h:44
PtypeProgress(SimpleState const &state)
static int getProgress(const SimpleState &state)
Definition: ptypeProgress.h:39
bool operator==(const PtypeProgress rhs) const
Definition: ptypeProgress.h:60
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
PtypeProgressTable Ptype_Progress_Table
Definition: ptypeProgress.cc:6
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
@ PTYPE_EMPTY
Definition: basic_type.h:85
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition: basic_type.h:199
@ PTYPEO_MIN
Definition: basic_type.h:200