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 {
39  StandPAWN=1,
40  StandLANCE=4,
41  StandKNIGHT=8,
42  StandSILVER=8,
43  StandGOLD=8,
44  StandBISHOP=12,
45  StandROOK=12,
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  };
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:
Effect5x3の差分計算で使うテーブル.
LongEffect const & getBlockEffect(Direction d, Offset32 offset32) const
5x3領域へのdirectionを限定した長い利きの計算.
unsigned int piecesOnStand(Ptype ptype) const
持駒のPtypeごとの寄与を表すテーブルの参照.
CArray3d< unsigned int, 2, Square::SIZE, 5 *3 > attackEffect
unsigned int countShortEffect(PtypeO ptypeO, Offset32 offset32) const
5x3領域への短い利きの数の計算.
座標の差分
Definition: basic_type.h:429
CArray2d< LongEffect4, PTYPEO_SIZE, Offset32::SIZE > longEffect
CArray< unsigned int, PTYPE_SIZE > onStand
CArray3d< unsigned int, 2, Square::SIZE, 5 *3 > defenseEffect
差が uniqになるような座標の差分.
Definition: offset32.h:16
CArray2d< LongEffect, 8, Offset32::SIZE > blockEffect
CArray< LongEffect, 4 > LongEffect4
長い利きの方向は高々4なので,長さ4のCArrayで表現.
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:83
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する. ...
Definition: basic_type.h:583
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
unsigned int getAttackEffect(Player pl, Square pos, int x, int y) const
unsigned int index() const
Definition: basic_type.h:572
unsigned int getDefenseEffect(Player pl, Square pos, int x, int y) const
unsigned int index() const
Definition: offset32.h:40
LongEffect4 const & getLongEffect(PtypeO ptypeO, Offset32 offset32) const
5x3領域へのPtypeOを限定した長い利きの計算.
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition: basic_type.h:199
Direction
Definition: basic_type.h:310
Effect5x3Table Effect5x3_Table
Player
Definition: basic_type.h:8
CArray2d< unsigned int, PTYPEO_SIZE, Offset32::SIZE > shortEffect
5x3領域への長い利きの始まりと終わり. offset - 利きの方向が0の時は利きが無いことを示す minIndex - 利...