My Project
myshogi.cc
Go to the documentation of this file.
1/* myshogi.cc
2 */
4#include "osl/record/ki2.h"
5#include <sstream>
6
7std::string osl::record::
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
39std::string osl::record::
40myshogi::show(const NumEffectState& state)
41{
42 static NumEffectState dummy;
43 return show(state, Move(), dummy);
44}
45
46std::string osl::record::
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
58std::string osl::record::
60{
61 std::string ret = "xx";
62 ret[0] = '0'+p.x();
63 ret[1] = '0'+p.y();
64 return ret;
65}
66
67std::string osl::record::
69{
70 if (! p.isOnBoard())
71 return "";
72 return std::string("\\koma{") + show(p.square()) + "}"
73 + "{" + show(p.owner()) + "}{" + show(p.ptype()) + "}";
74}
75
76std::string osl::record::
78{
79 return p == BLACK ? "\\sente" : "\\gote";
80}
81// ;;; Local Variables:
82// ;;; mode:c++
83// ;;; c-basic-offset:2
84// ;;; End:
圧縮していない moveの表現 .
bool isNormal() const
INVALID でも PASS でもない.
const Square to() const
利きを持つ局面
Ptype ptype() const
Definition basic_type.h:821
const Square square() const
Definition basic_type.h:832
Player owner() const
Definition basic_type.h:963
bool isOnBoard() const
Definition basic_type.h:985
const Piece pieceOf(int num) const
Definition simpleState.h:76
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
std::string show(const NumEffectState &state)
Definition myshogi.cc:40
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
Player
Definition basic_type.h:8
@ WHITE
Definition basic_type.h:10
@ BLACK
Definition basic_type.h:9