centering5x3.cc
Go to the documentation of this file.
00001 /* centering5x3.cc
00002  */
00003 #include "osl/centering5x3.h"
00004 #include "osl/square.h"
00005 
00006 osl::Centering5x3::
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 adjustCenterX(int x)
00023   {
00024     if (x < 3)
00025       return 3;
00026     else if (x > 7)
00027       return 7;
00028     return x;
00029   }
00030   int adjustCenterY(int y)
00031   {
00032     if (y == 1)
00033       return y+1;
00034     else if (y == 9)
00035       return y-1;
00036     return y;
00037   }
00038 } // anonymous namespace
00039 
00040 const osl::Square osl::
00041 Centering5x3::adjustCenterNaive(Square src)
00042 {
00043   const int x = adjustCenterX(src.x());
00044   const int y = adjustCenterY(src.y());
00045   return Square(x, y);
00046 }
00047 
00048 /* ------------------------------------------------------------------------- */
00049 // ;;; Local Variables:
00050 // ;;; mode:c++
00051 // ;;; c-basic-offset:2
00052 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines