My Project
std
osl
record
myshogi.cc
Go to the documentation of this file.
1
/* myshogi.cc
2
*/
3
#include "
osl/record/myshogi.h
"
4
#include "
osl/record/ki2.h
"
5
#include <sstream>
6
7
std::string
osl::record::
8
myshogi::show
(
const
NumEffectState
& state,
9
Move
last_move,
const
NumEffectState
& prev,
bool
add_csa_move)
10
{
11
std::ostringstream os;
12
os <<
"\\begin{myshogi}[.7] \\banmen \n"
;
13
os <<
"\\mochigoma{\\sente}"
;
14
for
(
Ptype
ptype: PieceStand::order)
15
os <<
"{"
<< state.
countPiecesOnStand
(
BLACK
, ptype) <<
"}"
;
16
os <<
"\n\\mochigoma{\\gote}"
;
17
for
(
Ptype
ptype: PieceStand::order)
18
os <<
"{"
<< state.
countPiecesOnStand
(
WHITE
, ptype) <<
"}"
;
19
os <<
"\n"
;
20
if
(last_move.
isNormal
()) {
21
os <<
"\\lastmove["
<< last_move.
to
().
x
() << last_move.
to
().
y
()
22
<<
"]{"
<<
ki2::show
(last_move, prev);
23
if
(add_csa_move)
24
os <<
'('
<<
csa::show
(last_move) <<
')'
;
25
os <<
"}\n"
;
26
}
27
for
(
int
i=0; i<Piece::SIZE; ++i)
28
{
29
const
Piece
p = state.
pieceOf
(i);
30
if
(p.
isOnBoard
())
31
os <<
show
(p);
32
if
(i % 2)
33
os <<
"\n"
;
34
}
35
os <<
"\\end{myshogi}\n"
;
36
return
os.str();
37
}
38
39
std::string
osl::record::
40
myshogi::show
(
const
NumEffectState
& state)
41
{
42
static
NumEffectState
dummy;
43
return
show
(state,
Move
(), dummy);
44
}
45
46
std::string
osl::record::
47
myshogi::show
(
Ptype
p)
48
{
49
static
CArray<std::string, PTYPE_SIZE>
names = {{
50
""
,
""
,
51
"\\tokin"
,
"\\narikyou"
,
"\\narikei"
,
"\\narigin"
,
"\\uma"
,
"\\ryu"
,
52
"\\ou"
,
// todo: \\gyoku
53
"\\kin"
,
"\\fu"
,
"\\kyou"
,
"\\kei"
,
"\\gin"
,
"\\kaku"
,
"\\hi"
54
}};
55
return
names[p];
56
}
57
58
std::string
osl::record::
59
myshogi::show
(
Square
p)
60
{
61
std::string ret =
"xx"
;
62
ret[0] =
'0'
+p.
x
();
63
ret[1] =
'0'
+p.
y
();
64
return
ret;
65
}
66
67
std::string
osl::record::
68
myshogi::show
(
Piece
p)
69
{
70
if
(! p.
isOnBoard
())
71
return
""
;
72
return
std::string(
"\\koma{"
) +
show
(p.
square
()) +
"}"
73
+
"{"
+
show
(p.
owner
()) +
"}{"
+
show
(p.
ptype
()) +
"}"
;
74
}
75
76
std::string
osl::record::
77
myshogi::show
(
Player
p)
78
{
79
return
p ==
BLACK
?
"\\sente"
:
"\\gote"
;
80
}
81
// ;;; Local Variables:
82
// ;;; mode:c++
83
// ;;; c-basic-offset:2
84
// ;;; End:
osl::Square
Definition:
basic_type.h:532
osl::WHITE
@ WHITE
Definition:
basic_type.h:10
osl::Move
圧縮していない moveの表現 .
Definition:
basic_type.h:1052
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition:
basic_type.h:84
osl::csa::show
const std::string show(Move)
Definition:
csa.cc:133
osl::Piece
駒.
Definition:
basic_type.h:788
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition:
simpleState.h:76
osl::record::myshogi::show
std::string show(const NumEffectState &state)
Definition:
myshogi.cc:40
ki2.h
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition:
basic_type.h:1088
osl::Piece::owner
Player owner() const
Definition:
basic_type.h:963
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition:
basic_type.h:563
osl::NumEffectState
利きを持つ局面
Definition:
numEffectState.h:34
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition:
basic_type.h:567
osl::Piece::square
const Square square() const
Definition:
basic_type.h:832
osl::Piece::ptype
Ptype ptype() const
Definition:
basic_type.h:821
myshogi.h
osl::BLACK
@ BLACK
Definition:
basic_type.h:9
osl::Player
Player
Definition:
basic_type.h:8
osl::CArray
Definition:
container.h:20
osl::Move::to
const Square to() const
Definition:
basic_type.h:1132
osl::Piece::isOnBoard
bool isOnBoard() const
Definition:
basic_type.h:985
osl::SimpleState::countPiecesOnStand
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
Definition:
simpleState.h:182
Generated by
1.8.20