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
24namespace
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:
static osl::SetUpRegister _initializer([](){ osl::Centering3x3::table.init();})
unsigned int index() const
Definition basic_type.h:572
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
static Table table
static const Square adjustCenterNaive(Square)