addEffectTable.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
addEffectTable.h
Go to the documentation of this file.
1 #ifndef _ADD_EFFECT_TABLE_H
2 #define _ADD_EFFECT_TABLE_H
3
4 #include "osl/ptype.h"
5 #include "osl/offset32.h"
6 #include "osl/container/nearMask.h"
7 #include "osl/misc/carray.h"
8 #include "osl/misc/carray2d.h"
9 #include "osl/misc/carray3d.h"
10
11 namespace osl
12 {
13 namespace move_generator
14 {
19 class AddEffectTable
20 {
21 CArray2d<NearMask, PTYPE_SIZE, Offset32::SIZE> nearMask;
22 CArray2d<NearMask, PTYPE_SIZE, Offset32::SIZE> nearMaskWithPromote;
23 CArray2d<NearMask, PTYPE_SIZE, Offset32::SIZE> nearMaskLong;
25 CArray3d<Offset,PTYPE_SIZE,Offset32::SIZE,8> offsetLong;
26 CArray<NearMask,Offset32::SIZE> nearMaskPBISHOP;
27 CArray2d<Offset,Offset32::SIZE,8> offsetPBISHOP;
28 CArray<NearMask,Offset32::SIZE> nearMaskPROOK;
29 CArray2d<Offset,Offset32::SIZE,8> offsetPROOK;
30 void setNearMaskLong(Ptype ptype,int dx, int dy);
31 public:
32 AddEffectTable();
39 template<Player P>
40 NearMask getNearMask(Ptype ptype,Square from, Square to) const{
41 assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
42 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
43 return nearMask[ptype][offset32.index()];
44 }
45 template<Player P>
46 NearMask getNearMaskWithPromote(Ptype ptype,Square from, Square to) const{
47 assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
48 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
49 return nearMaskWithPromote[ptype][offset32.index()];
50 }
51 template<Player P>
52 NearMask getNearMaskLong(Ptype ptype,Square from, Square to) const{
53 assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
54 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
55 return nearMaskLong[ptype][offset32.index()];
56 }
57 template<Player P>
58 Offset getOffsetLong(Ptype ptype,Square from, Square to,int n) const
59 {
60 assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard() &&
61 0<=n && n<8);
62 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
63 return offsetLong[ptype](offset32.index(),n);
64 }
65 template<Player P>
66 NearMask getNearMaskPBISHOP(Square from, Square to) const{
67 assert(from.isOnBoard() && to.isOnBoard());
68 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
69 return nearMaskPBISHOP[offset32.index()];
70 }
71 template<Player P>
72 Offset getOffsetPBISHOP(Square from, Square to,int n) const
73 {
74 assert(from.isOnBoard() && to.isOnBoard() && 0<=n && n<8);
75 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
76 return offsetPBISHOP(offset32.index(),n);
77 }
78 template<Player P>
79 NearMask getNearMaskPROOK(Square from, Square to) const{
80 assert(from.isOnBoard() && to.isOnBoard());
81 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
82 return nearMaskPROOK[offset32.index()];
83 }
84 template<Player P>
85 Offset getOffsetPROOK(Square from, Square to,int n) const
86 {
87 assert(from.isOnBoard() && to.isOnBoard() && 0<=n && n<8);
88 Offset32 offset32=Offset32(to,from).blackOffset32<P>();
89 return offsetPROOK(offset32.index(),n);
90 }
91 };
92
93 extern const AddEffectTable Add_Effect_Table;
94
95 } // namespace move_generator
96 } // namespace osl
97 #endif /* _ADD_EFFECT_TABLE_H */
98 // ;;; Local Variables:
99 // ;;; mode:c++
100 // ;;; c-basic-offset:2
101 // ;;; End: