addEffectTable.h
Go to the documentation of this file.
00001 #ifndef _ADD_EFFECT_TABLE_H
00002 #define _ADD_EFFECT_TABLE_H
00003 
00004 #include "osl/ptype.h"
00005 #include "osl/offset32.h"
00006 #include "osl/container/nearMask.h"
00007 #include "osl/misc/carray.h"
00008 #include "osl/misc/carray2d.h"
00009 #include "osl/misc/carray3d.h"
00010 
00011 namespace osl
00012 {
00013   namespace move_generator
00014   {
00019   class AddEffectTable
00020   {
00021     CArray2d<NearMask, PTYPE_SIZE, Offset32::SIZE> nearMask;
00022     CArray2d<NearMask, PTYPE_SIZE, Offset32::SIZE> nearMaskWithPromote;
00023     CArray2d<NearMask, PTYPE_SIZE, Offset32::SIZE> nearMaskLong;
00025     CArray3d<Offset,PTYPE_SIZE,Offset32::SIZE,8> offsetLong;
00026     CArray<NearMask,Offset32::SIZE> nearMaskPBISHOP;
00027     CArray2d<Offset,Offset32::SIZE,8> offsetPBISHOP;
00028     CArray<NearMask,Offset32::SIZE> nearMaskPROOK;
00029     CArray2d<Offset,Offset32::SIZE,8> offsetPROOK;
00030     void setNearMaskLong(Ptype ptype,int dx, int dy);
00031   public:
00032     AddEffectTable();
00039     template<Player P>
00040     NearMask getNearMask(Ptype ptype,Square from, Square to) const{
00041       assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
00042       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00043       return nearMask[ptype][offset32.index()];
00044     }
00045     template<Player P>
00046     NearMask getNearMaskWithPromote(Ptype ptype,Square from, Square to) const{
00047       assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
00048       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00049       return nearMaskWithPromote[ptype][offset32.index()];
00050     }
00051     template<Player P>
00052     NearMask getNearMaskLong(Ptype ptype,Square from, Square to) const{
00053       assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
00054       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00055       return nearMaskLong[ptype][offset32.index()];
00056     }
00057     template<Player P>
00058     Offset getOffsetLong(Ptype ptype,Square from, Square to,int n) const 
00059     {
00060       assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard() && 
00061              0<=n && n<8);
00062       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00063       return offsetLong[ptype](offset32.index(),n);
00064     }
00065     template<Player P>
00066     NearMask getNearMaskPBISHOP(Square from, Square to) const{
00067       assert(from.isOnBoard() && to.isOnBoard());
00068       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00069       return nearMaskPBISHOP[offset32.index()];
00070     }
00071     template<Player P>
00072     Offset getOffsetPBISHOP(Square from, Square to,int n) const 
00073     {
00074       assert(from.isOnBoard() && to.isOnBoard() && 0<=n && n<8);
00075       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00076       return offsetPBISHOP(offset32.index(),n);
00077     }
00078     template<Player P>
00079     NearMask getNearMaskPROOK(Square from, Square to) const{
00080       assert(from.isOnBoard() && to.isOnBoard());
00081       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00082       return nearMaskPROOK[offset32.index()];
00083     }
00084     template<Player P>
00085     Offset getOffsetPROOK(Square from, Square to,int n) const
00086     {
00087       assert(from.isOnBoard() && to.isOnBoard() && 0<=n && n<8);
00088       Offset32 offset32=Offset32(to,from).blackOffset32<P>();
00089       return offsetPROOK(offset32.index(),n);
00090     }
00091   };
00092 
00093   extern const AddEffectTable Add_Effect_Table;
00094 
00095   } // namespace move_generator
00096 } // namespace osl
00097 #endif /* _ADD_EFFECT_TABLE_H */
00098 // ;;; Local Variables:
00099 // ;;; mode:c++
00100 // ;;; c-basic-offset:2
00101 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines