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::
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::
41 {
42  static NumEffectState dummy;
43  return show(state, Move(), dummy);
44 }
45 
46 std::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 
58 std::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 
67 std::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 
76 std::string osl::record::
78 {
79  return p == BLACK ? "\\sente" : "\\gote";
80 }
81 // ;;; Local Variables:
82 // ;;; mode:c++
83 // ;;; c-basic-offset:2
84 // ;;; End:
bool isOnBoard() const
Definition: basic_type.h:985
Ptype ptype() const
Definition: basic_type.h:821
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
Definition: simpleState.h:182
bool isNormal() const
INVALID でも PASS でもない.
Definition: basic_type.h:1088
int y() const
将棋としてのY座標を返す.
Definition: basic_type.h:567
int x() const
将棋としてのX座標を返す.
Definition: basic_type.h:563
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:83
const Piece pieceOf(int num) const
Definition: simpleState.h:76
圧縮していない moveの表現 .
Definition: basic_type.h:1051
利きを持つ局面
const Square square() const
Definition: basic_type.h:832
const Square to() const
Definition: basic_type.h:1132
const std::string show(Move)
Definition: csa.cc:133
Player
Definition: basic_type.h:8
std::string show(const NumEffectState &state)
Definition: myshogi.cc:40
Player owner() const
Definition: basic_type.h:963