My Project
effect5x3Table.h
Go to the documentation of this file.
1 /* effect5x3Table.h
2  */
3 #ifndef _PROGRESS_EFFECT5X3_TABLE_H
4 #define _PROGRESS_EFFECT5X3_TABLE_H
5 
6 #include "osl/basic_type.h"
7 #include "osl/container.h"
8 #include "osl/bits/offset32.h"
9 #include <iosfwd>
10 
11 namespace osl
12 {
13  namespace progress
14  {
21  struct LongEffect
22  {
24  unsigned short minIndex;
25  unsigned short maxIndex;
26  };
31 
36  {
37  public:
38  enum {
46  };
47  private:
54  void setupOnStand();
55  void setupShortEffect();
56  void setupLongEffect();
57  void setupBlockEffect();
58  void setupAttackEffect();
59  void setupDefenseEffect();
60  public:
61  void init();
71  unsigned int piecesOnStand(Ptype ptype) const
72  {
73  return onStand[ptype];
74  }
81  unsigned int countShortEffect(PtypeO ptypeO,Offset32 offset32) const
82  {
83  return shortEffect[ptypeO-PTYPEO_MIN][offset32.index()];
84  }
91  LongEffect4 const& getLongEffect(PtypeO ptypeO,Offset32 offset32) const
92  {
93  return longEffect[ptypeO-PTYPEO_MIN][offset32.index()];
94  }
100  LongEffect const& getBlockEffect(Direction d,Offset32 offset32) const
101  {
102  assert(d<8);
103  return blockEffect[d][offset32.index()];
104  }
105  unsigned int getAttackEffect(Player pl,Square pos,int x,int y) const
106  {
107  assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
108  return attackEffect[pl][pos.index()][x*3+y];
109  }
110  unsigned int getDefenseEffect(Player pl,Square pos,int x,int y) const
111  {
112  assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
113  return defenseEffect[pl][pos.index()][x*3+y];
114  }
115  };
116  extern Effect5x3Table Effect5x3_Table;
117  std::ostream& operator<<(std::ostream& os,LongEffect const& longEffect);
118  }
119 }
120 #endif /* _PROGRESS_EFFECT5X3_TABLE_H */
121 // ;;; Local Variables:
122 // ;;; mode:c++
123 // ;;; c-basic-offset:2
124 // ;;; End:
osl::progress::Effect5x3Table::getLongEffect
LongEffect4 const & getLongEffect(PtypeO ptypeO, Offset32 offset32) const
5x3領域へのPtypeOを限定した長い利きの計算.
Definition: effect5x3Table.h:91
osl::Square
Definition: basic_type.h:532
osl::progress::Effect5x3_Table
Effect5x3Table Effect5x3_Table
Definition: effect5x3Table.cc:13
osl::progress::Effect5x3Table::StandROOK
@ StandROOK
Definition: effect5x3Table.h:45
osl::progress::LongEffect::maxIndex
unsigned short maxIndex
Definition: effect5x3Table.h:25
osl::progress::Effect5x3Table::defenseEffect
CArray3d< unsigned int, 2, Square::SIZE, 5 *3 > defenseEffect
Definition: effect5x3Table.h:53
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
Definition: basic_type.h:583
osl::progress::Effect5x3Table::longEffect
CArray2d< LongEffect4, PTYPEO_SIZE, Offset32::SIZE > longEffect
Definition: effect5x3Table.h:50
osl::progress::LongEffect4
CArray< LongEffect, 4 > LongEffect4
長い利きの方向は高々4なので,長さ4のCArrayで表現.
Definition: effect5x3Table.h:30
osl::progress::Effect5x3Table::setupBlockEffect
void setupBlockEffect()
Definition: effect5x3Table.cc:146
osl::progress::Effect5x3Table::setupDefenseEffect
void setupDefenseEffect()
Definition: effect5x3Table.cc:206
osl::progress::operator<<
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
Definition: effect5x3Table.cc:106
basic_type.h
osl::Offset
座標の差分
Definition: basic_type.h:430
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::progress::Effect5x3Table::shortEffect
CArray2d< unsigned int, PTYPEO_SIZE, Offset32::SIZE > shortEffect
Definition: effect5x3Table.h:49
osl::progress::Effect5x3Table::attackEffect
CArray3d< unsigned int, 2, Square::SIZE, 5 *3 > attackEffect
Definition: effect5x3Table.h:52
osl::progress::Effect5x3Table::StandPAWN
@ StandPAWN
Definition: effect5x3Table.h:39
osl::progress::Effect5x3Table::StandLANCE
@ StandLANCE
Definition: effect5x3Table.h:40
osl::progress::LongEffect::minIndex
unsigned short minIndex
Definition: effect5x3Table.h:24
osl::progress::Effect5x3Table::blockEffect
CArray2d< LongEffect, 8, Offset32::SIZE > blockEffect
Definition: effect5x3Table.h:51
osl::Square::index
unsigned int index() const
Definition: basic_type.h:572
osl::progress::Effect5x3Table::StandBISHOP
@ StandBISHOP
Definition: effect5x3Table.h:44
container.h
osl::progress::Effect5x3Table::getBlockEffect
LongEffect const & getBlockEffect(Direction d, Offset32 offset32) const
5x3領域へのdirectionを限定した長い利きの計算.
Definition: effect5x3Table.h:100
osl::progress::Effect5x3Table::init
void init()
Definition: effect5x3Table.cc:236
osl::Offset32Base
差が uniqになるような座標の差分.
Definition: offset32.h:17
osl::progress::Effect5x3Table
Effect5x3の差分計算で使うテーブル.
Definition: effect5x3Table.h:36
osl::PtypeO
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition: basic_type.h:199
osl::Direction
Direction
Definition: basic_type.h:310
offset32.h
osl::PTYPEO_MIN
@ PTYPEO_MIN
Definition: basic_type.h:200
osl::Offset32Base::index
unsigned int index() const
Definition: offset32.h:40
osl::progress::Effect5x3Table::onStand
CArray< unsigned int, PTYPE_SIZE > onStand
Definition: effect5x3Table.h:48
osl::progress::LongEffect::offset
Offset offset
Definition: effect5x3Table.h:23
osl::progress::Effect5x3Table::setupShortEffect
void setupShortEffect()
Definition: effect5x3Table.cc:131
osl::progress::Effect5x3Table::getAttackEffect
unsigned int getAttackEffect(Player pl, Square pos, int x, int y) const
Definition: effect5x3Table.h:105
osl::progress::Effect5x3Table::setupLongEffect
void setupLongEffect()
Definition: effect5x3Table.cc:161
osl::progress::Effect5x3Table::StandKNIGHT
@ StandKNIGHT
Definition: effect5x3Table.h:41
osl::Player
Player
Definition: basic_type.h:8
osl::progress::LongEffect
5x3領域への長い利きの始まりと終わり. offset - 利きの方向が0の時は利きが無いことを示す minIndex - 利きが領域に入るindex maxIndex - 利きが領域から出る手前のin...
Definition: effect5x3Table.h:22
osl::progress::Effect5x3Table::getDefenseEffect
unsigned int getDefenseEffect(Player pl, Square pos, int x, int y) const
Definition: effect5x3Table.h:110
osl::progress::Effect5x3Table::piecesOnStand
unsigned int piecesOnStand(Ptype ptype) const
持駒のPtypeごとの寄与を表すテーブルの参照.
Definition: effect5x3Table.h:71
osl::progress::Effect5x3Table::StandGOLD
@ StandGOLD
Definition: effect5x3Table.h:43
osl::CArray
Definition: container.h:20
osl::progress::Effect5x3Table::countShortEffect
unsigned int countShortEffect(PtypeO ptypeO, Offset32 offset32) const
5x3領域への短い利きの数の計算.
Definition: effect5x3Table.h:81
osl::progress::Effect5x3Table::setupAttackEffect
void setupAttackEffect()
Definition: effect5x3Table.cc:177
osl::progress::Effect5x3Table::StandSILVER
@ StandSILVER
Definition: effect5x3Table.h:42
osl::progress::Effect5x3Table::setupOnStand
void setupOnStand()
Definition: effect5x3Table.cc:114
osl
Definition: additionalEffect.h:6