My Project
boardTable.cc
Go to the documentation of this file.
1 /* directionTable.cc
2  */
3 #include "osl/bits/boardTable.h"
5 
6 template <osl::Direction Dir>
8  const int blackDx=DirectionTraits<Dir>::blackDx;
9  const int blackDy=DirectionTraits<Dir>::blackDy;
10  Offset offset=Offset(blackDx,blackDy);
11 #ifndef MINIMAL
12  space_counts[Offset32Wide(0,0).index()]=0;
13 #endif
14  for(int i=1;i<=8;i++){
15  int dx=i*blackDx;
16  int dy=i*blackDy;
17  Offset32 offset32(dx,dy);
18  directions[offset32.index()]=Dir;
19  short_offsets[offset32.index()]=offset;
20  short_offsets_not_knight[offset32.index()]=offset;
22  longToShort(Dir);
24  offset.intValue();
25  }
26 #ifndef MINIMAL
27  for(int i=1;i<=10;i++){
28  int dx=i*blackDx;
29  int dy=i*blackDy;
30  Offset32Wide offset32w(dx,dy);
31  space_counts[offset32w.index()]=i-1;
32  }
33 #endif
34 }
35 template <osl::Direction Dir>
39  Offset32 offset32=Offset32(dx,dy);
40  Offset offset=Offset(dx,dy);
41  short_offsets[offset32.index()]=offset;
42  short_offsets[(-offset32).index()]= -offset;
43 }
44 
46  short8Dir.fill(DIRECTION_INVALID_VALUE);
47  short8Offset.fill();
48  directions.fill();
49  short_offsets_not_knight.fill();
50 #ifndef MINIMAL
51  space_counts.fill(-1);
52 #endif
53  setDirections<LONG_UL>();
54  setDirections<LONG_U>();
55  setDirections<LONG_UR>();
56  setDirections<LONG_L>();
57  setDirections<LONG_R>();
58  setDirections<LONG_DL>();
59  setDirections<LONG_D>();
60  setDirections<LONG_DR>();
61  setKnightDirections<UUL>();
62  setKnightDirections<UUR>();
63 }
64 
66  init();
67  assert(! getOffset(BLACK, UL).zero());
68 }
69 
70 /* ------------------------------------------------------------------------- */
71 // ;;; Local Variables:
72 // ;;; mode:c++
73 // ;;; c-basic-offset:2
74 // ;;; End:
osl::Offset32Wide
Offset32Base< 10, 10 > Offset32Wide
Definition: offset32.h:64
osl::BoardTable::space_counts
CArray< int, Offset32Wide::SIZE > space_counts
Definition: boardTable.h:21
osl::BoardTable::init
void init()
Definition: boardTable.cc:45
osl::BoardTable::short8Offset
CArray< signed char, Offset::ONBOARD_OFFSET_SIZE > short8Offset
Definition: boardTable.h:16
boardTable.h
directionTraits.h
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition: offset32.h:63
osl::Offset
座標の差分
Definition: basic_type.h:430
osl::BoardTable::BoardTable
BoardTable()
Definition: boardTable.cc:65
osl::DIRECTION_INVALID_VALUE
@ DIRECTION_INVALID_VALUE
Definition: basic_type.h:338
osl::Offset32Base
差が uniqになるような座標の差分.
Definition: offset32.h:17
osl::Offset::ONBOARD_OFFSET_MIN
@ ONBOARD_OFFSET_MIN
Definition: basic_type.h:434
osl::BoardTable::short_offsets
CArray< Offset, Offset32::SIZE > short_offsets
Definition: boardTable.h:18
osl::BoardTable::setDirections
void setDirections()
Definition: boardTable.cc:7
osl::BoardTable::setKnightDirections
void setKnightDirections()
Definition: boardTable.cc:36
osl::BoardTable::directions
CArray< Direction, Offset32::SIZE > directions
Definition: boardTable.h:14
osl::longToShort
constexpr Direction longToShort(Direction d)
Definition: basic_type.h:380
osl::Offset32Base::index
unsigned int index() const
Definition: offset32.h:40
osl::BLACK
@ BLACK
Definition: basic_type.h:9
osl::BoardTable::short8Dir
CArray< unsigned char, Offset::ONBOARD_OFFSET_SIZE > short8Dir
Definition: boardTable.h:17
osl::BoardTable::short_offsets_not_knight
CArray< Offset, Offset32::SIZE > short_offsets_not_knight
Definition: boardTable.h:19
osl::Offset::intValue
int intValue() const
Definition: basic_type.h:448
osl::UL
@ UL
Definition: basic_type.h:313
osl::DirectionTraits
Definition: directionTraits.h:225