説明を見る。00001
00002
00003 #include "osl/record/myshogi.h"
00004 #include "osl/record/ki2.h"
00005 #include <sstream>
00006
00007 std::string osl::record::
00008 myshogi::show(const NumEffectState& state,
00009 Move last_move, const NumEffectState& prev, bool add_csa_move)
00010 {
00011 std::ostringstream os;
00012 os << "\\begin{myshogi}[.7] \\banmen \n";
00013 os << "\\mochigoma{\\sente}";
00014 for (Ptype ptype: PieceStand::order)
00015 os << "{" << state.countPiecesOnStand(BLACK, ptype) << "}";
00016 os << "\n\\mochigoma{\\gote}";
00017 for (Ptype ptype: PieceStand::order)
00018 os << "{" << state.countPiecesOnStand(WHITE, ptype) << "}";
00019 os << "\n";
00020 if (last_move.isNormal()) {
00021 os << "\\lastmove[" << last_move.to().x() << last_move.to().y()
00022 << "]{" << ki2::show(last_move, prev);
00023 if (add_csa_move)
00024 os << '(' << csa::show(last_move) << ')';
00025 os << "}\n";
00026 }
00027 for (int i=0; i<Piece::SIZE; ++i)
00028 {
00029 const Piece p = state.pieceOf(i);
00030 if (p.isOnBoard())
00031 os << show(p);
00032 if (i % 2)
00033 os << "\n";
00034 }
00035 os << "\\end{myshogi}\n";
00036 return os.str();
00037 }
00038
00039 std::string osl::record::
00040 myshogi::show(const NumEffectState& state)
00041 {
00042 static NumEffectState dummy;
00043 return show(state, Move(), dummy);
00044 }
00045
00046 std::string osl::record::
00047 myshogi::show(Ptype p)
00048 {
00049 static CArray<std::string, PTYPE_SIZE> names = {{
00050 "", "",
00051 "\\tokin", "\\narikyou", "\\narikei", "\\narigin", "\\uma", "\\ryu",
00052 "\\ou",
00053 "\\kin", "\\fu", "\\kyou", "\\kei", "\\gin", "\\kaku", "\\hi"
00054 }};
00055 return names[p];
00056 }
00057
00058 std::string osl::record::
00059 myshogi::show(Square p)
00060 {
00061 std::string ret = "xx";
00062 ret[0] = '0'+p.x();
00063 ret[1] = '0'+p.y();
00064 return ret;
00065 }
00066
00067 std::string osl::record::
00068 myshogi::show(Piece p)
00069 {
00070 if (! p.isOnBoard())
00071 return "";
00072 return std::string("\\koma{") + show(p.square()) + "}"
00073 + "{" + show(p.owner()) + "}{" + show(p.ptype()) + "}";
00074 }
00075
00076 std::string osl::record::
00077 myshogi::show(Player p)
00078 {
00079 return p == BLACK ? "\\sente" : "\\gote";
00080 }
00081
00082
00083
00084