Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
lib
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 "
osl/record/csa.h
"
6
#include "
osl/pieceStand.h
"
7
#include <boost/foreach.hpp>
8
#include <sstream>
9
10
std::string
osl::record::
11
myshogi::show
(
const
NumEffectState& state,
12
Move
last_move,
const
NumEffectState& prev,
bool
add_csa_move)
13
{
14
std::ostringstream os;
15
os <<
"\\begin{myshogi}[.7] \\banmen \n"
;
16
os <<
"\\mochigoma{\\sente}"
;
17
BOOST_FOREACH(
Ptype
ptype,
PieceStand::order
)
18
os <<
"{"
<< state.countPiecesOnStand(
BLACK
, ptype) <<
"}"
;
19
os <<
"\n\\mochigoma{\\gote}"
;
20
BOOST_FOREACH(
Ptype
ptype,
PieceStand::order
)
21
os <<
"{"
<< state.countPiecesOnStand(
WHITE
, ptype) <<
"}"
;
22
os <<
"\n"
;
23
if
(last_move.
isNormal
()) {
24
os <<
"\\lastmove["
<< last_move.
to
().
x
() << last_move.
to
().
y
()
25
<<
"]{"
<<
ki2::show
(last_move, prev);
26
if
(add_csa_move)
27
os <<
'('
<<
csa::show
(last_move) <<
')'
;
28
os <<
"}\n"
;
29
}
30
for
(
int
i=0; i<Piece::SIZE; ++i)
31
{
32
const
Piece
p = state.pieceOf(i);
33
if
(p.
isOnBoard
())
34
os <<
show
(p);
35
if
(i % 2)
36
os <<
"\n"
;
37
}
38
os <<
"\\end{myshogi}\n"
;
39
return
os.str();
40
}
41
42
std::string
osl::record::
43
myshogi::show
(
const
NumEffectState& state)
44
{
45
static
NumEffectState dummy;
46
return
show
(state,
Move
(), dummy);
47
}
48
49
std::string
osl::record::
50
myshogi::show
(
Ptype
p)
51
{
52
static
CArray<std::string, PTYPE_SIZE> names = {{
53
""
,
""
,
54
"\\tokin"
,
"\\narikyou"
,
"\\narikei"
,
"\\narigin"
,
"\\uma"
,
"\\ryu"
,
55
"\\ou"
,
// todo: \\gyoku
56
"\\kin"
,
"\\fu"
,
"\\kyou"
,
"\\kei"
,
"\\gin"
,
"\\kaku"
,
"\\hi"
57
}};
58
return
names[p];
59
}
60
61
std::string
osl::record::
62
myshogi::show
(
Square
p)
63
{
64
std::string ret =
"xx"
;
65
ret[0] =
'0'
+p.
x
();
66
ret[1] =
'0'
+p.
y
();
67
return
ret;
68
}
69
70
std::string
osl::record::
71
myshogi::show
(
Piece
p)
72
{
73
if
(! p.
isOnBoard
())
74
return
""
;
75
return
std::string(
"\\koma{"
) +
show
(p.
square
()) +
"}"
76
+
"{"
+
show
(p.
owner
()) +
"}{"
+
show
(p.
ptype
()) +
"}"
;
77
}
78
79
std::string
osl::record::
80
myshogi::show
(
Player
p)
81
{
82
return
p ==
BLACK
?
"\\sente"
:
"\\gote"
;
83
}
84
// ;;; Local Variables:
85
// ;;; mode:c++
86
// ;;; c-basic-offset:2
87
// ;;; End:
Generated on Sun Jul 21 2013 13:37:25 by
1.8.4