centering3x3.cc
Go to the documentation of this file.
/* centering3x3.cc
*/
#include "osl/centering3x3.h"
#include "osl/oslConfig.h"
osl::Centering3x3::Table osl::Centering3x3::table;
static osl::SetUpRegister _initializer([](){ osl::Centering3x3::table.init(); });
void osl::Centering3x3::
Table::init()
{
centers.fill(Square::STAND());
for (int y=1; y<=9; ++y)
{
for (int x=1; x<=9; ++x)
{
const Square src = Square(x,y);
centers[src.index()] = adjustCenterNaive(src);
}
}
}
namespace
{
int adjustCenterXY(int xy)
{
if (xy == 1)
return xy+1;
else if (xy == 9)
return xy-1;
return xy;
}
} // anonymous namespace
const osl::Square osl::
Centering3x3::adjustCenterNaive(Square src)
{
const int x = adjustCenterXY(src.x());
const int y = adjustCenterXY(src.y());
return Square(x, y);
}
/* ------------------------------------------------------------------------- */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
_initializer
static osl::SetUpRegister _initializer([](){ osl::Centering3x3::table.init();})
centering3x3.h
osl::Square
Definition basic_type.h:532
osl::Square::index
unsigned int index() const
Definition basic_type.h:572
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::STAND
static const Square STAND()
Definition basic_type.h:548
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
oslConfig.h
osl::Centering3x3::Table
Definition centering3x3.h:16
osl::Centering3x3::Table::init
void init()
Definition centering3x3.cc:11
osl::Centering3x3::Table::centers
CArray< Square, Square::SIZE > centers
Definition centering3x3.h:17
osl::Centering3x3::table
static Table table
Definition centering3x3.h:21
osl::Centering3x3::adjustCenterNaive
static const Square adjustCenterNaive(Square)
Definition centering3x3.cc:37
osl::SetUpRegister
Definition oslConfig.h:128