My Project
centering3x3.cc
Go to the documentation of this file.
1 /* centering3x3.cc
2  */
3 #include "osl/centering3x3.h"
4 #include "osl/oslConfig.h"
5 
7 
9 
12 {
13  centers.fill(Square::STAND());
14  for (int y=1; y<=9; ++y)
15  {
16  for (int x=1; x<=9; ++x)
17  {
18  const Square src = Square(x,y);
19  centers[src.index()] = adjustCenterNaive(src);
20  }
21  }
22 }
23 
24 namespace
25 {
26  int adjustCenterXY(int xy)
27  {
28  if (xy == 1)
29  return xy+1;
30  else if (xy == 9)
31  return xy-1;
32  return xy;
33  }
34 } // anonymous namespace
35 
38 {
39  const int x = adjustCenterXY(src.x());
40  const int y = adjustCenterXY(src.y());
41  return Square(x, y);
42 }
43 
44 /* ------------------------------------------------------------------------- */
45 // ;;; Local Variables:
46 // ;;; mode:c++
47 // ;;; c-basic-offset:2
48 // ;;; End:
osl::Square
Definition: basic_type.h:532
osl::SetUpRegister
Definition: oslConfig.h:128
_initializer
static osl::SetUpRegister _initializer([](){ osl::Centering3x3::table.init();})
centering3x3.h
osl::Square::index
unsigned int index() const
Definition: basic_type.h:572
osl::Centering3x3::adjustCenterNaive
static const Square adjustCenterNaive(Square)
Definition: centering3x3.cc:37
oslConfig.h
osl::Centering3x3::Table
Definition: centering3x3.h:16
osl::Centering3x3::table
static Table table
Definition: centering3x3.h:21
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition: basic_type.h:563
osl::Centering3x3::Table::init
void init()
Definition: centering3x3.cc:11
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition: basic_type.h:567
osl::Square::STAND
static const Square STAND()
Definition: basic_type.h:548