ptypeProgress.h
Go to the documentation of this file.
/* ptpeProgress.h
*/
#ifndef PROGRESS_PTYPE_PROGRESS_H
#define PROGRESS_PTYPE_PROGRESS_H
#include "osl/numEffectState.h"
#include <iosfwd>
namespace osl
{
namespace progress
{
class PtypeProgressTable
{
private:
CArray<int,PTYPE_SIZE> ptype2Val;
CArray2d<int,PTYPEO_SIZE,Square::SIZE> pos2Val;
static const CArray<int,10> yVals;
public:
void init();
~PtypeProgressTable();
int progress(PtypeO ptypeo,Square pos) const{
return pos2Val[ptypeo-PTYPEO_MIN][pos.index()];
}
};
extern PtypeProgressTable Ptype_Progress_Table;
class PtypeProgress
{
int val;
public:
explicit PtypeProgress(SimpleState const& state);
int progress() const{ return val; }
private:
void addVal(int d) { val+=d; }
public:
void changeTurn() {}
static int getProgress(const SimpleState& state)
{
const PtypeProgress progress(state);
return progress.progress();
}
void update(const SimpleState& , Move last_move)
{
const PtypeO ptypeo = last_move.ptypeO();
if (last_move.isDrop()) {
val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
- Ptype_Progress_Table.progress(ptypeo,Square::STAND());
return;
}
val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
- Ptype_Progress_Table.progress(ptypeo,last_move.from());
Ptype ptype = last_move.capturePtype();
if (ptype != PTYPE_EMPTY)
val += Ptype_Progress_Table.progress(last_move.capturePtypeO(), Square::STAND())
- Ptype_Progress_Table.progress(last_move.capturePtypeO(), last_move.to());
}
bool operator==(const PtypeProgress rhs) const { return val == rhs.val; }
};
std::ostream& operator<<(std::ostream& os, PtypeProgress prog);
} // namespace progress
using progress::PtypeProgress;
} // namespace osl
#endif /* PROGRESS_PTYPE_PROGRESS_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; coding:utf-8
// ;;; End:
osl::CArray
Definition container.h:20
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::ptypeO
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Definition basic_type.h:1162
osl::Move::isDrop
bool isDrop() const
Definition basic_type.h:1150
osl::Move::capturePtype
Ptype capturePtype() const
Definition basic_type.h:1180
osl::Move::capturePtypeO
PtypeO capturePtypeO() const
Definition basic_type.h:1185
osl::Move::to
const Square to() const
Definition basic_type.h:1132
osl::Move::from
const Square from() const
Definition basic_type.h:1125
osl::SimpleState
Definition simpleState.h:35
osl::Square
Definition basic_type.h:532
osl::Square::index
unsigned int index() const
Definition basic_type.h:572
osl::Square::STAND
static const Square STAND()
Definition basic_type.h:548
osl::progress::PtypeProgressTable
ゲームの進行度を駒が自陣からどの程度前に進んでいるかの和で表現
Definition ptypeProgress.h:15
osl::progress::PtypeProgressTable::~PtypeProgressTable
~PtypeProgressTable()
Definition ptypeProgress.cc:146
osl::progress::PtypeProgressTable::yVals
static const CArray< int, 10 > yVals
y 座標に対応した進行度の係数、最初は0 (使用しない)
Definition ptypeProgress.h:11
osl::progress::PtypeProgressTable::progress
int progress(PtypeO ptypeo, Square pos) const
Definition ptypeProgress.h:23
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::progress::PtypeProgressTable::init
void init()
Definition ptypeProgress.cc:113
osl::progress::PtypeProgress
Definition ptypeProgress.h:30
osl::progress::PtypeProgress::addVal
void addVal(int d)
Definition ptypeProgress.h:36
osl::progress::PtypeProgress::progress
int progress() const
Definition ptypeProgress.h:34
osl::progress::PtypeProgress::changeTurn
void changeTurn()
Definition ptypeProgress.h:38
osl::progress::PtypeProgress::val
int val
Definition ptypeProgress.h:31
osl::progress::PtypeProgress::update
void update(const SimpleState &, Move last_move)
Definition ptypeProgress.h:44
osl::progress::PtypeProgress::PtypeProgress
PtypeProgress(SimpleState const &state)
Definition ptypeProgress.cc:91
osl::progress::PtypeProgress::getProgress
static int getProgress(const SimpleState &state)
Definition ptypeProgress.h:39
osl::progress::PtypeProgress::operator==
bool operator==(const PtypeProgress rhs) const
Definition ptypeProgress.h:60
osl::progress
Definition progress.cc:754
osl::progress::operator<<
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
Definition effect5x3Table.cc:106
osl::progress::Ptype_Progress_Table
PtypeProgressTable Ptype_Progress_Table
Definition ptypeProgress.cc:6
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition basic_type.h:85
osl::CArray2d
CArray< CArray< T, Capacity2 >, Capacity1 > CArray2d
Definition container.h:95
osl::PtypeO
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition basic_type.h:199
osl::PTYPEO_MIN
@ PTYPEO_MIN
Definition basic_type.h:200
numEffectState.h