effect5x3Table.h
Go to the documentation of this file.
/* effect5x3Table.h
*/
#ifndef _PROGRESS_EFFECT5X3_TABLE_H
#define _PROGRESS_EFFECT5X3_TABLE_H
#include "osl/basic_type.h"
#include "osl/container.h"
#include "osl/bits/offset32.h"
#include <iosfwd>
namespace osl
{
namespace progress
{
struct LongEffect
{
Offset offset;
unsigned short minIndex;
unsigned short maxIndex;
};
typedef CArray<LongEffect,4> LongEffect4;
class Effect5x3Table
{
public:
enum {
StandPAWN=1,
StandLANCE=4,
StandKNIGHT=8,
StandSILVER=8,
StandGOLD=8,
StandBISHOP=12,
StandROOK=12,
};
private:
CArray<unsigned int,PTYPE_SIZE> onStand;
CArray2d<unsigned int,PTYPEO_SIZE,Offset32::SIZE> shortEffect;
CArray2d<LongEffect4,PTYPEO_SIZE,Offset32::SIZE> longEffect;
CArray2d<LongEffect,8,Offset32::SIZE> blockEffect;
CArray3d<unsigned int,2,Square::SIZE,5*3> attackEffect;
CArray3d<unsigned int,2,Square::SIZE,5*3> defenseEffect;
void setupOnStand();
void setupShortEffect();
void setupLongEffect();
void setupBlockEffect();
void setupAttackEffect();
void setupDefenseEffect();
public:
void init();
unsigned int piecesOnStand(Ptype ptype) const
{
return onStand[ptype];
}
unsigned int countShortEffect(PtypeO ptypeO,Offset32 offset32) const
{
return shortEffect[ptypeO-PTYPEO_MIN][offset32.index()];
}
LongEffect4 const& getLongEffect(PtypeO ptypeO,Offset32 offset32) const
{
return longEffect[ptypeO-PTYPEO_MIN][offset32.index()];
}
LongEffect const& getBlockEffect(Direction d,Offset32 offset32) const
{
assert(d<8);
return blockEffect[d][offset32.index()];
}
unsigned int getAttackEffect(Player pl,Square pos,int x,int y) const
{
assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
return attackEffect[pl][pos.index()][x*3+y];
}
unsigned int getDefenseEffect(Player pl,Square pos,int x,int y) const
{
assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
return defenseEffect[pl][pos.index()][x*3+y];
}
};
extern Effect5x3Table Effect5x3_Table;
std::ostream& operator<<(std::ostream& os,LongEffect const& longEffect);
}
}
#endif /* _PROGRESS_EFFECT5X3_TABLE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
basic_type.h
osl::CArray
Definition container.h:20
osl::Offset32Base::index
unsigned int index() const
Definition offset32.h:40
osl::Offset
座標の差分
Definition basic_type.h:430
osl::Square
Definition basic_type.h:532
osl::Square::index
unsigned int index() const
Definition basic_type.h:572
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定． 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する．
Definition basic_type.h:583
osl::progress::Effect5x3Table
Effect5x3の差分計算で使うテーブル.
Definition effect5x3Table.h:36
osl::progress::Effect5x3Table::setupBlockEffect
void setupBlockEffect()
Definition effect5x3Table.cc:146
osl::progress::Effect5x3Table::attackEffect
CArray3d< unsigned int, 2, Square::SIZE, 5 *3 > attackEffect
Definition effect5x3Table.h:52
osl::progress::Effect5x3Table::longEffect
CArray2d< LongEffect4, PTYPEO_SIZE, Offset32::SIZE > longEffect
Definition effect5x3Table.h:50
osl::progress::Effect5x3Table::setupOnStand
void setupOnStand()
Definition effect5x3Table.cc:114
osl::progress::Effect5x3Table::shortEffect
CArray2d< unsigned int, PTYPEO_SIZE, Offset32::SIZE > shortEffect
Definition effect5x3Table.h:49
osl::progress::Effect5x3Table::blockEffect
CArray2d< LongEffect, 8, Offset32::SIZE > blockEffect
Definition effect5x3Table.h:51
osl::progress::Effect5x3Table::setupLongEffect
void setupLongEffect()
Definition effect5x3Table.cc:161
osl::progress::Effect5x3Table::defenseEffect
CArray3d< unsigned int, 2, Square::SIZE, 5 *3 > defenseEffect
Definition effect5x3Table.h:53
osl::progress::Effect5x3Table::init
void init()
Definition effect5x3Table.cc:236
osl::progress::Effect5x3Table::getBlockEffect
LongEffect const & getBlockEffect(Direction d, Offset32 offset32) const
5x3領域へのdirectionを限定した長い利きの計算.
Definition effect5x3Table.h:100
osl::progress::Effect5x3Table::onStand
CArray< unsigned int, PTYPE_SIZE > onStand
Definition effect5x3Table.h:48
osl::progress::Effect5x3Table::piecesOnStand
unsigned int piecesOnStand(Ptype ptype) const
持駒のPtypeごとの寄与を表すテーブルの参照.
Definition effect5x3Table.h:71
osl::progress::Effect5x3Table::StandPAWN
@ StandPAWN
Definition effect5x3Table.h:39
osl::progress::Effect5x3Table::StandSILVER
@ StandSILVER
Definition effect5x3Table.h:42
osl::progress::Effect5x3Table::StandGOLD
@ StandGOLD
Definition effect5x3Table.h:43
osl::progress::Effect5x3Table::StandROOK
@ StandROOK
Definition effect5x3Table.h:45
osl::progress::Effect5x3Table::StandLANCE
@ StandLANCE
Definition effect5x3Table.h:40
osl::progress::Effect5x3Table::StandKNIGHT
@ StandKNIGHT
Definition effect5x3Table.h:41
osl::progress::Effect5x3Table::StandBISHOP
@ StandBISHOP
Definition effect5x3Table.h:44
osl::progress::Effect5x3Table::getAttackEffect
unsigned int getAttackEffect(Player pl, Square pos, int x, int y) const
Definition effect5x3Table.h:105
osl::progress::Effect5x3Table::setupShortEffect
void setupShortEffect()
Definition effect5x3Table.cc:131
osl::progress::Effect5x3Table::getLongEffect
LongEffect4 const & getLongEffect(PtypeO ptypeO, Offset32 offset32) const
5x3領域へのPtypeOを限定した長い利きの計算.
Definition effect5x3Table.h:91
osl::progress::Effect5x3Table::setupAttackEffect
void setupAttackEffect()
Definition effect5x3Table.cc:177
osl::progress::Effect5x3Table::getDefenseEffect
unsigned int getDefenseEffect(Player pl, Square pos, int x, int y) const
Definition effect5x3Table.h:110
osl::progress::Effect5x3Table::setupDefenseEffect
void setupDefenseEffect()
Definition effect5x3Table.cc:206
osl::progress::Effect5x3Table::countShortEffect
unsigned int countShortEffect(PtypeO ptypeO, Offset32 offset32) const
5x3領域への短い利きの数の計算.
Definition effect5x3Table.h:81
container.h
osl::progress
Definition progress.cc:754
osl::progress::operator<<
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
Definition effect5x3Table.cc:106
osl::progress::LongEffect4
CArray< LongEffect, 4 > LongEffect4
長い利きの方向は高々4なので，長さ4のCArrayで表現．
Definition effect5x3Table.h:30
osl::progress::Effect5x3_Table
Effect5x3Table Effect5x3_Table
Definition effect5x3Table.cc:13
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::CArray3d
CArray< CArray2d< T, Capacity2, Capacity3 >, Capacity1 > CArray3d
Definition container.h:98
osl::CArray2d
CArray< CArray< T, Capacity2 >, Capacity1 > CArray2d
Definition container.h:95
osl::Direction
Direction
Definition basic_type.h:310
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition offset32.h:63
osl::Player
Player
Definition basic_type.h:8
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
offset32.h
osl::progress::LongEffect
5x3領域への長い利きの始まりと終わり． offset - 利きの方向が0の時は利きが無いことを示す minIndex - 利きが領域に入るindex maxIndex - 利きが領域から出る手前のin...
Definition effect5x3Table.h:22
osl::progress::LongEffect::maxIndex
unsigned short maxIndex
Definition effect5x3Table.h:25
osl::progress::LongEffect::offset
Offset offset
Definition effect5x3Table.h:23
osl::progress::LongEffect::minIndex
unsigned short minIndex
Definition effect5x3Table.h:24