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