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