mobilityTable.h
Go to the documentation of this file.
1 /* mobilityTable.h
2  */
3 #ifndef _MOBILITY_TABLE_H
4 #define _MOBILITY_TABLE_H
5 #include "osl/basic_type.h"
6 #include "osl/simpleState.h"
7 #include <cassert>
8 #include <iosfwd>
9 
10 namespace osl
11 {
12  namespace mobility
13  {
14  union V4 {
15  unsigned int lv;
17  }
18 #ifdef __GNUC__
19  __attribute__((aligned(4)))
20 #endif
21  ;
30  {
31  V4 v;
32  public:
34  clear();
35  }
36  void clear(){
37  v.lv=0u;
38  }
39  const Square get(Direction d) const{
40  return Square::makeDirect(v.uc[((unsigned int)d)>>1]);
41  }
42  void set(Direction d,Square pos){
43  v.uc[((unsigned int)d)>>1]=static_cast<unsigned char>(pos.uintValue());
44  }
45  };
46  std::ostream& operator<<(std::ostream& os,MobilityContent const& mc);
47 
52  {
54 #ifdef __GNUC__
55  __attribute__((aligned(16)))
56 #endif
57  ;
58  public:
60  MobilityTable(SimpleState const& state);
61  void set(Direction d,int num,Square pos){
62  assert(0<=(int)d && (int)d<=7);
63  return table[num-32].set(d,pos);
64  }
65  const Square get(Direction d,int num) const{
66  assert(0<=(int)d && (int)d<=7);
67  return table[num-32].get(d);
68  }
69  friend bool operator==(const MobilityTable& mt1,const MobilityTable& mt2);
70  };
71  std::ostream& operator<<(std::ostream& os,MobilityTable const& mt);
72  bool operator==(const MobilityTable&,const MobilityTable&);
73  }
75 }
76 #endif /* _MOBILITY_TABLE_H */
77 // ;;; Local Variables:
78 // ;;; mode:c++
79 // ;;; c-basic-offset:2
80 // ;;; End:
CArray< unsigned char, 4 > uc
Definition: mobilityTable.h:16
static const Square makeDirect(int value)
Definition: basic_type.h:538
駒毎に指定の方向の利きを持つ最後のSquare.
Definition: mobilityTable.h:29
long long v2di __attribute__((vector_size(16)))
Definition: kingMobility.h:22
std::ostream & operator<<(std::ostream &os, MobilityContent const &mc)
unsigned int lv
Definition: mobilityTable.h:15
駒番号からMobilityContentを得る
Definition: mobilityTable.h:51
Direction
Definition: basic_type.h:310
bool operator==(const MobilityTable &, const MobilityTable &)