All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
liberty8Table.h
Go to the documentation of this file.
1 /* liberty8Table.h
2  */
3 #ifndef _LIBERTY8TABLE_H
4 #define _LIBERTY8TABLE_H
5 #include "osl/ptype.h"
6 #include "osl/ptypeTable.h"
8 #include "osl/misc/carray.h"
9 #include "osl/misc/carray2d.h"
10 #include <iosfwd>
11 namespace osl
12 {
13  namespace effect
14  {
20  struct LongEffect8
21  {
22  friend std::ostream& operator<<(std::ostream& os,LongEffect8 const& longEffect);
27  CArray<unsigned char,3> mask;
28  public:
30  mask[0]=mask[1]=mask[2]=0;
31  }
32  Offset getOffset() const{
34  }
35  void setOffset(Offset o){
36  smallOffset=static_cast<char>(o.intValue());
37  }
38  unsigned int getMask(int index) const{
39  return static_cast<unsigned int>(mask[index]);
40  }
41  void setMask(int index,unsigned int val) {
42  mask[index]=static_cast<unsigned char>(val);
43  }
44  };
52  CArray<CArray<unsigned char,Offset32::SIZE>,PTYPE_SIZE> shortMask;
53  CArray2d<LongEffect8,PTYPE_SIZE,Offset32::SIZE> longEffect;
54  CArray<LongEffect8,Offset32::SIZE> longEffect2;
55  LongEffect8 longEffectOf(Ptype ptype,int dx,int dy);
56  public:
57  Liberty8Table();
65  template<Player P>
66  NearMask getShortMask(Ptype ptype,Square from, Square to) const{
67  assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
68  Offset32 offset32=Offset32(to,from).blackOffset32<P>();
69  return NearMask::makeDirect(shortMask[ptype][offset32.index()]);
70  }
76  template<Player P>
77  LongEffect8 getLongEffect(Ptype ptype,Square from, Square to) const{
78  assert(isValid(ptype) && from.isOnBoard() && to.isOnBoard());
79  assert(Ptype_Table.hasLongMove(ptype));
80  Offset32 offset32=Offset32(to,from).blackOffset32<P>();
81  return longEffect[ptype][offset32.index()];
82  }
87  template<Player P>
89  assert(from.isOnBoard() && to.isOnBoard());
90  Offset32 offset32=Offset32(to,from).blackOffset32<P>();
91  return longEffect2[offset32.index()];
92  }
93  };
94 
95  extern const Liberty8Table Liberty8_Table;
96 } // namespace effect
97 } // namespace osl
98 #endif /* _LIBERTY8TABLE_H */
99 // ;;; Local Variables:
100 // ;;; mode:c++
101 // ;;; c-basic-offset:2
102 // ;;; End:
103