addEffect8Table.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
addEffect8Table.h
Go to the documentation of this file.
1 #ifndef _ADD_EFFECT8_TABLE_H
2 #define _ADD_EFFECT8_TABLE_H
3
4 #include "osl/ptype.h"
5 #include "osl/offset32.h"
6 #include "osl/misc/carray.h"
7 #include "osl/misc/carray2d.h"
8 #include "osl/misc/carray3d.h"
9
10 #include <utility>
11
12 namespace osl
13 {
14 namespace move_generator
15 {
16 namespace addeffect8
17 {
22 typedef std::pair<Offset,Offset> OffsetPair;
23 typedef std::pair<Square,Offset> PO;
24 typedef std::pair<Square,OffsetPair> POO;
25 class AddEffect8Table
26 {
27 static const int maxDropSquare=32;
28 CArray3d<Square,PTYPE_SIZE,Square::SIZE,maxDropSquare> dropSquare;
29 static const int maxLongDropDirect=8;
30 CArray3d<Offset,PTYPE_SIZE,Square::SIZE,maxLongDropDirect> longDropDirect;
31
32 static const int maxLongDropSquare=32;
33 CArray3d<PO,PTYPE_SIZE,Square::SIZE,maxLongDropSquare> longDropSquare;
34 static const int maxLongDrop2Square=8;
35 CArray3d<POO,PTYPE_SIZE,Square::SIZE,maxLongDrop2Square> longDrop2Square;
36
37 static const int maxShortMoveOffset=32;
38 CArray3d<Offset,PTYPE_SIZE,Offset32::SIZE,maxShortMoveOffset> shortMoveOffset;
39 static const int maxShortPromoteMoveOffset=32;
40 CArray3d<Offset,PTYPE_SIZE,Offset32::SIZE,maxShortPromoteMoveOffset> shortPromoteMoveOffset;
41 static const int maxLongMoveOffset=32;
42 CArray3d<OffsetPair,PTYPE_SIZE,Offset32::SIZE,maxLongMoveOffset> longMoveOffset;
43 CArray2d<OffsetPair,PTYPE_SIZE,Offset32::SIZE> betweenOffset;
44 public:
45 AddEffect8Table();
46
53 Square getDropSquare(Ptype ptype,Square kingSquare,int i) const
54 {
55 // std::cerr << "getDropOffset(" << ptype << "," << i << ")" << std::endl;
56 return dropSquare[ptype](kingSquare.index(),i);
57 }
58
63 Offset getLongDropDirect(Ptype ptype,Square kingSquare,int i) const
64 {
65 return longDropDirect[ptype](kingSquare.index(),i);
66 }
67
74 PO getLongDropSquare(Ptype ptype,Square kingSquare,int i) const
75 {
76 return longDropSquare[ptype](kingSquare.index(),i);
77 }
78
85 POO getLongDrop2Square(Ptype ptype,Square kingSquare,int i) const
86 {
87 return longDrop2Square[ptype](kingSquare.index(),i);
88 }
89
99 Offset getShortMoveOffset(bool isPromote,Ptype ptype,Offset32 o32,int i) const
100 {
101 if(!isPromote){
102 assert(i<maxShortMoveOffset);
103 return shortMoveOffset[ptype](o32.index(),i);
104 }
105 else{
106 assert(i<maxShortPromoteMoveOffset);
107 return shortPromoteMoveOffset[ptype](o32.index(),i);
108 }
109 }
118 OffsetPair getLongMoveOffset(Ptype ptype,Offset32 o32,int i) const
119 {
120 assert(i<maxLongMoveOffset);
121 return longMoveOffset[ptype](o32.index(),i);
122 }
129 OffsetPair getBetweenOffset(Ptype ptype,Offset32 o32) const
130 {
131 return betweenOffset[ptype][o32.index()];
132 }
133 private:
134 void initDropSquare();
135 void initLongDropSquare();
136 void initMoveOffset();
137 };
138 }
139 extern const addeffect8::AddEffect8Table Add_Effect8_Table;
140
141 } // namespace move_generator
142 } // namespace osl
143 #endif /* _ADD_EFFECT8_TABLE_H */
144 // ;;; Local Variables:
145 // ;;; mode:c++
146 // ;;; c-basic-offset:2
147 // ;;; End: