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:
osl::progress::PtypeProgress::val
int val
Definition: ptypeProgress.h:31
osl::progress::PtypeProgress::getProgress
static int getProgress(const SimpleState &state)
Definition: ptypeProgress.h:39
osl::Square
Definition: basic_type.h:532
osl::progress::PtypeProgressTable
ゲームの進行度を駒が自陣からどの程度前に進んでいるかの和で表現
Definition: ptypeProgress.h:15
osl::progress::PtypeProgress::operator==
bool operator==(const PtypeProgress rhs) const
Definition: ptypeProgress.h:60
osl::progress::PtypeProgress::PtypeProgress
PtypeProgress(SimpleState const &state)
Definition: ptypeProgress.cc:91
osl::progress::PtypeProgressTable::init
void init()
Definition: ptypeProgress.cc:113
osl::progress::PtypeProgressTable::~PtypeProgressTable
~PtypeProgressTable()
Definition: ptypeProgress.cc:146
osl::progress::operator<<
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
Definition: effect5x3Table.cc:106
osl::Move
圧縮していない moveの表現 .
Definition: basic_type.h:1052
osl::progress::PtypeProgress::addVal
void addVal(int d)
Definition: ptypeProgress.h:36
osl::SimpleState
Definition: simpleState.h:35
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::progress::PtypeProgressTable::pos2Val
CArray2d< int, PTYPEO_SIZE, Square::SIZE > pos2Val
Definition: ptypeProgress.h:18
osl::progress::PtypeProgressTable::ptype2Val
CArray< int, PTYPE_SIZE > ptype2Val
Definition: ptypeProgress.h:17
osl::Square::index
unsigned int index() const
Definition: basic_type.h:572
osl::Move::capturePtype
Ptype capturePtype() const
Definition: basic_type.h:1180
osl::Move::isDrop
bool isDrop() const
Definition: basic_type.h:1150
osl::Move::ptypeO
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Definition: basic_type.h:1162
osl::progress::PtypeProgressTable::progress
int progress(PtypeO ptypeo, Square pos) const
Definition: ptypeProgress.h:23
osl::Move::from
const Square from() const
Definition: basic_type.h:1125
osl::progress::Ptype_Progress_Table
PtypeProgressTable Ptype_Progress_Table
Definition: ptypeProgress.cc:6
osl::PtypeO
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition: basic_type.h:199
osl::progress::PtypeProgressTable::yVals
static const CArray< int, 10 > yVals
y 座標に対応した進行度の係数、最初は0 (使用しない)
Definition: ptypeProgress.h:19
osl::progress::PtypeProgress::changeTurn
void changeTurn()
Definition: ptypeProgress.h:38
osl::progress::PtypeProgress::update
void update(const SimpleState &, Move last_move)
Definition: ptypeProgress.h:44
osl::PTYPEO_MIN
@ PTYPEO_MIN
Definition: basic_type.h:200
osl::Move::capturePtypeO
PtypeO capturePtypeO() const
Definition: basic_type.h:1185
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition: basic_type.h:85
numEffectState.h
osl::progress::PtypeProgress::progress
int progress() const
Definition: ptypeProgress.h:34
osl::Square::STAND
static const Square STAND()
Definition: basic_type.h:548
osl::CArray< int, PTYPE_SIZE >
osl::Move::to
const Square to() const
Definition: basic_type.h:1132
osl::progress::PtypeProgress
Definition: ptypeProgress.h:30
osl
Definition: additionalEffect.h:6