My Project
centering5x3.cc
Go to the documentation of this file.
1/* centering5x3.cc
2 */
4#include "osl/basic_type.h"
5
8{
9 centers.fill(Square::STAND());
10 for (int y=1; y<=9; ++y)
11 {
12 for (int x=1; x<=9; ++x)
13 {
14 const Square src = Square(x,y);
15 centers[src.index()] = adjustCenterNaive(src);
16 }
17 }
18}
19
20namespace
21{
22 int adjustCenterX(int x)
23 {
24 if (x < 3)
25 return 3;
26 else if (x > 7)
27 return 7;
28 return x;
29 }
30 int adjustCenterY(int y)
31 {
32 if (y == 1)
33 return y+1;
34 else if (y == 9)
35 return y-1;
36 return y;
37 }
38} // anonymous namespace
39
42{
43 const int x = adjustCenterX(src.x());
44 const int y = adjustCenterY(src.y());
45 return Square(x, y);
46}
47
48/* ------------------------------------------------------------------------- */
49// ;;; Local Variables:
50// ;;; mode:c++
51// ;;; c-basic-offset:2
52// ;;; End:
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 const Square adjustCenterNaive(Square)