00001 /* centering3x3.cc 00002 */ 00003 #include "osl/centering3x3.h" 00004 #include "osl/oslConfig.h" 00005 00006 osl::Centering3x3::Table osl::Centering3x3::table; 00007 00008 static osl::SetUpRegister _initializer([](){ osl::Centering3x3::table.init(); }); 00009 00010 void osl::Centering3x3:: 00011 Table::init() 00012 { 00013 centers.fill(Square::STAND()); 00014 for (int y=1; y<=9; ++y) 00015 { 00016 for (int x=1; x<=9; ++x) 00017 { 00018 const Square src = Square(x,y); 00019 centers[src.index()] = adjustCenterNaive(src); 00020 } 00021 } 00022 } 00023 00024 namespace 00025 { 00026 int adjustCenterXY(int xy) 00027 { 00028 if (xy == 1) 00029 return xy+1; 00030 else if (xy == 9) 00031 return xy-1; 00032 return xy; 00033 } 00034 } // anonymous namespace 00035 00036 const osl::Square osl:: 00037 Centering3x3::adjustCenterNaive(Square src) 00038 { 00039 const int x = adjustCenterXY(src.x()); 00040 const int y = adjustCenterXY(src.y()); 00041 return Square(x, y); 00042 } 00043 00044 /* ------------------------------------------------------------------------- */ 00045 // ;;; Local Variables: 00046 // ;;; mode:c++ 00047 // ;;; c-basic-offset:2 00048 // ;;; End: