centering3x3.cc
Go to the documentation of this file.
00001 /* centering3x3.cc
00002  */
00003 #include "osl/centering3x3.h"
00004 #include "osl/square.h"
00005 
00006 osl::Centering3x3::
00007 Table::Table()
00008 {
00009   centers.fill(Square::STAND());
00010   for (int y=1; y<=9; ++y)
00011   {
00012     for (int x=1; x<=9; ++x)
00013     {
00014       const Square src = Square(x,y);
00015       centers[src.index()] = adjustCenterNaive(src);
00016     }
00017   }
00018 }
00019 
00020 namespace
00021 {
00022   int adjustCenterXY(int xy)
00023   {
00024     if (xy == 1)
00025       return xy+1;
00026     else if (xy == 9)
00027       return xy-1;
00028     return xy;
00029   }
00030 } // anonymous namespace
00031 
00032 const osl::Square osl::
00033 Centering3x3::adjustCenterNaive(Square src)
00034 {
00035   const int x = adjustCenterXY(src.x());
00036   const int y = adjustCenterXY(src.y());
00037   return Square(x, y);
00038 }
00039 
00040 /* ------------------------------------------------------------------------- */
00041 // ;;; Local Variables:
00042 // ;;; mode:c++
00043 // ;;; c-basic-offset:2
00044 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines