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
7#include <iosfwd>
8namespace osl
9{
10 namespace progress
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の表現 .
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
bool isDrop() const
Ptype capturePtype() const
PtypeO capturePtypeO() const
const Square to() const
const Square from() const
unsigned int index() const
Definition basic_type.h:572
static const Square STAND()
Definition basic_type.h:548
ゲームの進行度を駒が自陣からどの程度前に進んでいるかの和で表現
static const CArray< int, 10 > yVals
y 座標に対応した進行度の係数、最初は0 (使用しない)
int progress(PtypeO ptypeo, Square pos) const
CArray2d< int, PTYPEO_SIZE, Square::SIZE > pos2Val
CArray< int, PTYPE_SIZE > ptype2Val
void update(const SimpleState &, Move last_move)
static int getProgress(const SimpleState &state)
bool operator==(const PtypeProgress rhs) const
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
PtypeProgressTable Ptype_Progress_Table
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