00001
00002
00003 #include "osl/record/myshogi.h"
00004 #include "osl/pieceStand.h"
00005 #include <boost/foreach.hpp>
00006 #include <sstream>
00007
00008 std::string osl::record::
00009 myshogi::show(const NumEffectState& state)
00010 {
00011 std::ostringstream os;
00012 os << "\\begin{myshogi} \\banmen \n";
00013 os << "\\mochigoma{\\sente}";
00014 BOOST_FOREACH(Ptype ptype, PieceStand::order)
00015 os << "{" << state.countPiecesOnStand(BLACK, ptype) << "}";
00016 os << "\n\\mochigoma{\\gote}";
00017 BOOST_FOREACH(Ptype ptype, PieceStand::order)
00018 os << "{" << state.countPiecesOnStand(WHITE, ptype) << "}";
00019 os << "\n";
00020 for (int i=0; i<Piece::SIZE; ++i)
00021 {
00022 const Piece p = state.getPieceOf(i);
00023 if (p.isOnBoard())
00024 os << show(p);
00025 if (i % 2)
00026 os << "\n";
00027 }
00028 os << "\\end{myshogi}\n";
00029 return os.str();
00030 }
00031
00032 std::string osl::record::
00033 myshogi::show(Ptype p)
00034 {
00035 static CArray<std::string, PTYPE_SIZE> names = {{
00036 "", "",
00037 "\\tokin", "\\narikyou", "\\narikei", "\\narigin", "\\uma", "\\ryu",
00038 "\\ou",
00039 "\\kin", "\\fu", "\\kyou", "\\kei", "\\gin", "\\kaku", "\\hi"
00040 }};
00041 return names[p];
00042 }
00043
00044 std::string osl::record::
00045 myshogi::show(Position p)
00046 {
00047 std::string ret = "xx";
00048 ret[0] = '0'+p.x();
00049 ret[1] = '0'+p.y();
00050 return ret;
00051 }
00052
00053 std::string osl::record::
00054 myshogi::show(Piece p)
00055 {
00056 if (! p.isOnBoard())
00057 return "";
00058 return std::string("\\koma{") + show(p.position()) + "}"
00059 + "{" + show(p.owner()) + "}{" + show(p.ptype()) + "}";
00060 }
00061
00062 std::string osl::record::
00063 myshogi::show(Player p)
00064 {
00065 return p == BLACK ? "\\sente" : "\\gote";
00066 }
00067
00068
00069
00070