myshogi.cc
Go to the documentation of this file.
/* myshogi.cc
*/
#include "osl/record/myshogi.h"
#include "osl/record/ki2.h"
#include <sstream>
std::string osl::record::
myshogi::show(const NumEffectState& state,
Move last_move, const NumEffectState& prev, bool add_csa_move)
{
std::ostringstream os;
os << "\\begin{myshogi}[.7] \\banmen \n";
os << "\\mochigoma{\\sente}";
for (Ptype ptype: PieceStand::order)
os << "{" << state.countPiecesOnStand(BLACK, ptype) << "}";
os << "\n\\mochigoma{\\gote}";
for (Ptype ptype: PieceStand::order)
os << "{" << state.countPiecesOnStand(WHITE, ptype) << "}";
os << "\n";
if (last_move.isNormal()) {
os << "\\lastmove[" << last_move.to().x() << last_move.to().y()
<< "]{" << ki2::show(last_move, prev);
if (add_csa_move)
os << '(' << csa::show(last_move) << ')';
os << "}\n";
}
for (int i=0; i<Piece::SIZE; ++i)
{
const Piece p = state.pieceOf(i);
if (p.isOnBoard())
os << show(p);
if (i % 2)
os << "\n";
}
os << "\\end{myshogi}\n";
return os.str();
}
std::string osl::record::
myshogi::show(const NumEffectState& state)
{
static NumEffectState dummy;
return show(state, Move(), dummy);
}
std::string osl::record::
myshogi::show(Ptype p)
{
static CArray<std::string, PTYPE_SIZE> names = {{
"", "",
"\\tokin", "\\narikyou", "\\narikei", "\\narigin", "\\uma", "\\ryu",
"\\ou", // todo: \\gyoku
"\\kin", "\\fu", "\\kyou", "\\kei", "\\gin", "\\kaku", "\\hi"
}};
return names[p];
}
std::string osl::record::
myshogi::show(Square p)
{
std::string ret = "xx";
ret[0] = '0'+p.x();
ret[1] = '0'+p.y();
return ret;
}
std::string osl::record::
myshogi::show(Piece p)
{
if (! p.isOnBoard())
return "";
return std::string("\\koma{") + show(p.square()) + "}"
+ "{" + show(p.owner()) + "}{" + show(p.ptype()) + "}";
}
std::string osl::record::
myshogi::show(Player p)
{
return p == BLACK ? "\\sente" : "\\gote";
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::CArray
Definition container.h:20
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition basic_type.h:1088
osl::Move::to
const Square to() const
Definition basic_type.h:1132
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::PieceStand::order
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
Definition bits/pieceStand.h:41
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::Piece::square
const Square square() const
Definition basic_type.h:832
osl::Piece::owner
Player owner() const
Definition basic_type.h:963
osl::Piece::isOnBoard
bool isOnBoard() const
Definition basic_type.h:985
osl::Piece::SIZE
static const int SIZE
Definition basic_type.h:794
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition simpleState.h:76
osl::SimpleState::countPiecesOnStand
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
Definition simpleState.h:182
osl::Square
Definition basic_type.h:532
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
ki2.h
myshogi.h
osl::csa::show
const std::string show(Move)
Definition csa.cc:133
osl::ki2::show
const std::string show(Square)
Definition ki2.cc:133
osl::record::myshogi::show
std::string show(const NumEffectState &state)
Definition myshogi.cc:40
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::Player
Player
Definition basic_type.h:8
osl::WHITE
@ WHITE
Definition basic_type.h:10
osl::BLACK
@ BLACK
Definition basic_type.h:9