My Project
std
osl
centering3x3.cc
Go to the documentation of this file.
1
/* centering3x3.cc
2
*/
3
#include "
osl/centering3x3.h
"
4
#include "
osl/oslConfig.h
"
5
6
osl::Centering3x3::Table
osl::Centering3x3::table
;
7
8
static
osl::SetUpRegister
_initializer
([](){
osl::Centering3x3::table
.
init
(); });
9
10
void
osl::Centering3x3::
11
Table::init
()
12
{
13
centers.fill(Square::STAND());
14
for
(
int
y=1; y<=9; ++y)
15
{
16
for
(
int
x=1; x<=9; ++x)
17
{
18
const
Square
src =
Square
(x,y);
19
centers[src.
index
()] = adjustCenterNaive(src);
20
}
21
}
22
}
23
24
namespace
25
{
26
int
adjustCenterXY(
int
xy)
27
{
28
if
(xy == 1)
29
return
xy+1;
30
else
if
(xy == 9)
31
return
xy-1;
32
return
xy;
33
}
34
}
// anonymous namespace
35
36
const
osl::Square
osl::
37
Centering3x3::adjustCenterNaive
(
Square
src)
38
{
39
const
int
x = adjustCenterXY(src.
x
());
40
const
int
y = adjustCenterXY(src.
y
());
41
return
Square
(x, y);
42
}
43
44
/* ------------------------------------------------------------------------- */
45
// ;;; Local Variables:
46
// ;;; mode:c++
47
// ;;; c-basic-offset:2
48
// ;;; 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::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
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
Generated by
1.9.8