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,Position from, Position 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,Position from, Position 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,Position from, Position 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,Position from, Position 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(Position from, Position 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(Position from, Position 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(Position from, Position 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(Position from, Position 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 }
00096 }
00097 #endif
00098
00099
00100
00101