addEffect8Table.h
Go to the documentation of this file.
00001 #ifndef _ADD_EFFECT8_TABLE_H
00002 #define _ADD_EFFECT8_TABLE_H
00003 
00004 #include "osl/ptype.h"
00005 #include "osl/offset32.h"
00006 #include "osl/misc/carray.h"
00007 #include "osl/misc/carray2d.h"
00008 #include "osl/misc/carray3d.h"
00009 
00010 #include <utility>
00011 
00012 namespace osl
00013 {
00014   namespace move_generator
00015   {
00016     namespace addeffect8
00017     {
00022     typedef std::pair<Offset,Offset> OffsetPair;
00023     typedef std::pair<Square,Offset> PO;
00024     typedef std::pair<Square,OffsetPair> POO;
00025     class AddEffect8Table
00026     {
00027       static const int maxDropSquare=32;
00028       CArray3d<Square,PTYPE_SIZE,Square::SIZE,maxDropSquare> dropSquare;
00029       static const int maxLongDropDirect=8;
00030       CArray3d<Offset,PTYPE_SIZE,Square::SIZE,maxLongDropDirect> longDropDirect;
00031 
00032       static const int maxLongDropSquare=32;
00033       CArray3d<PO,PTYPE_SIZE,Square::SIZE,maxLongDropSquare> longDropSquare;
00034       static const int maxLongDrop2Square=8;
00035       CArray3d<POO,PTYPE_SIZE,Square::SIZE,maxLongDrop2Square> longDrop2Square;
00036 
00037       static const int maxShortMoveOffset=32;
00038       CArray3d<Offset,PTYPE_SIZE,Offset32::SIZE,maxShortMoveOffset> shortMoveOffset;
00039       static const int maxShortPromoteMoveOffset=32;
00040       CArray3d<Offset,PTYPE_SIZE,Offset32::SIZE,maxShortPromoteMoveOffset> shortPromoteMoveOffset;
00041       static const int maxLongMoveOffset=32;
00042       CArray3d<OffsetPair,PTYPE_SIZE,Offset32::SIZE,maxLongMoveOffset> longMoveOffset;
00043       CArray2d<OffsetPair,PTYPE_SIZE,Offset32::SIZE> betweenOffset;
00044     public:
00045       AddEffect8Table();
00046 
00053       Square getDropSquare(Ptype ptype,Square kingSquare,int i) const
00054       {
00055         //      std::cerr << "getDropOffset(" << ptype << "," << i << ")" << std::endl;
00056         return dropSquare[ptype](kingSquare.index(),i);
00057       }
00058 
00063       Offset getLongDropDirect(Ptype ptype,Square kingSquare,int i) const
00064       {
00065         return longDropDirect[ptype](kingSquare.index(),i);
00066       }
00067 
00074       PO getLongDropSquare(Ptype ptype,Square kingSquare,int i) const
00075       {
00076         return longDropSquare[ptype](kingSquare.index(),i);
00077       }
00078 
00085       POO getLongDrop2Square(Ptype ptype,Square kingSquare,int i) const
00086       {
00087         return longDrop2Square[ptype](kingSquare.index(),i);
00088       }
00089 
00099       Offset getShortMoveOffset(bool isPromote,Ptype ptype,Offset32 o32,int i) const
00100       {
00101         if(!isPromote){
00102           assert(i<maxShortMoveOffset);
00103           return shortMoveOffset[ptype](o32.index(),i);
00104         }
00105         else{
00106           assert(i<maxShortPromoteMoveOffset);
00107           return shortPromoteMoveOffset[ptype](o32.index(),i);
00108         }
00109       }
00118       OffsetPair getLongMoveOffset(Ptype ptype,Offset32 o32,int i) const
00119       {
00120         assert(i<maxLongMoveOffset);
00121         return longMoveOffset[ptype](o32.index(),i);
00122       }
00129       OffsetPair getBetweenOffset(Ptype ptype,Offset32 o32) const
00130       {
00131         return betweenOffset[ptype][o32.index()];
00132       }
00133     private:
00134       void initDropSquare();
00135       void initLongDropSquare();
00136       void initMoveOffset();
00137     };
00138     }
00139     extern const addeffect8::AddEffect8Table Add_Effect8_Table;
00140 
00141   } // namespace move_generator
00142 } // namespace osl
00143 #endif /* _ADD_EFFECT8_TABLE_H */
00144 // ;;; Local Variables:
00145 // ;;; mode:c++
00146 // ;;; c-basic-offset:2
00147 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines