All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
centering5x3.cc
Go to the documentation of this file.
1 /* centering5x3.cc
2  */
3 #include "osl/centering5x3.h"
4 #include "osl/square.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 
20 namespace
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 
40 const osl::Square osl::
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: