simpleState.cc
Go to the documentation of this file.
/* simpleState.cc
*/
#include "osl/simpleState.h"
#include "osl/simpleState.tcc"
#include "osl/csa.h"
#include "osl/bits/pieceTable.h"
#include "osl/bits/pieceStand.h"
#include <iostream>
#include <stdexcept>
osl::SimpleState::SimpleState() {
init();
}
osl::SimpleState::SimpleState(Handicap h) {
init(h);
}
void osl::SimpleState::initPawnMask(){
for (Ptype ptype: PieceStand::order) {
stand_count[BLACK][ptype - PTYPE_BASIC_MIN] = countPiecesOnStandBit(BLACK, ptype);
stand_count[WHITE][ptype - PTYPE_BASIC_MIN] = countPiecesOnStandBit(WHITE, ptype);
}
pawnMask[0].clearAll();
pawnMask[1].clearAll();
for(int num=PtypeTraits<PAWN>::indexMin;
num< PtypeTraits<PAWN>::indexLimit; num++){
Piece p=pieceOf(num);
Player player=p.owner();
Square pos=p.square();
if(!pos.isPieceStand() && !p.isPromotedNotKingGold()){
if (isPawnMaskSet(player,pos.x()))
{
throw CsaIOError("2FU!");
}
pawnMask[player].set(pos);
}
}
assert(isConsistent(true));
}
void osl::SimpleState::init() {
player_to_move=BLACK;
for (int ipos=0;ipos<Square::SIZE;ipos++) {
setBoard(Square::nth(ipos),Piece::EDGE());
}
for (int y=1;y<=9;y++)
for (int x=9;x>0;x--) {
setBoard(Square(x,y),Piece::EMPTY());
}
// promoteMask.clearAll();
stand_mask[BLACK].resetAll();
stand_mask[WHITE].resetAll();
stand_count[BLACK].fill(0);
stand_count[WHITE].fill(0);
used_mask.resetAll();
pawnMask[0].clearAll();
pawnMask[1].clearAll();
for (int num=0;num<Piece::SIZE;num++){
pieces[num]=Piece(WHITE,Piece_Table.getPtypeOf(num),num,Square::STAND());
}
}
void osl::SimpleState::init(Handicap h) {
init();
if (h != HIRATE) {
std::cerr << "unsupported handicap\n";
throw std::runtime_error("unsupported handicap");
}
// 歩
for (int x=9;x>0;x--) {
setPiece(BLACK,Square(x,7),PAWN);
setPiece(WHITE,Square(x,3),PAWN);
}
//
setPiece(BLACK,Square(1,9),LANCE);
setPiece(BLACK,Square(9,9),LANCE);
setPiece(WHITE,Square(1,1),LANCE);
setPiece(WHITE,Square(9,1),LANCE);
//
setPiece(BLACK,Square(2,9),KNIGHT);
setPiece(BLACK,Square(8,9),KNIGHT);
setPiece(WHITE,Square(2,1),KNIGHT);
setPiece(WHITE,Square(8,1),KNIGHT);
//
setPiece(BLACK,Square(3,9),SILVER);
setPiece(BLACK,Square(7,9),SILVER);
setPiece(WHITE,Square(3,1),SILVER);
setPiece(WHITE,Square(7,1),SILVER);
//
setPiece(BLACK,Square(4,9),GOLD);
setPiece(BLACK,Square(6,9),GOLD);
setPiece(WHITE,Square(4,1),GOLD);
setPiece(WHITE,Square(6,1),GOLD);
//
setPiece(BLACK,Square(5,9),KING);
setPiece(WHITE,Square(5,1),KING);
//
setPiece(BLACK,Square(8,8),BISHOP);
setPiece(WHITE,Square(2,2),BISHOP);
//
setPiece(BLACK,Square(2,8),ROOK);
setPiece(WHITE,Square(8,2),ROOK);
initPawnMask();
}
osl::SimpleState::~SimpleState() {}
void osl::SimpleState::setPiece(Player player,Square pos,Ptype ptype) {
int num;
for (num=0;num<40;num++) {
if (!used_mask.test(num) && Piece_Table.getPtypeOf(num)==unpromote(ptype)
&& (ptype!=KING ||
num==PtypeTraits<KING>::indexMin+playerToIndex(player))) {
used_mask.set(num);
Piece p(player,ptype,num,pos);
setPieceOf(num,p);
if (pos.isPieceStand())
stand_mask[player].set(num);
else{
setBoard(pos,p);
if (ptype==PAWN)
pawnMask[player].set(pos);
}
return;
}
}
std::cerr << "osl::SimpleState::setPiece! maybe too many pieces "
<< ptype << " " << pos << " " << player << "\n";
abort();
}
void osl::SimpleState::setPieceAll(Player player) {
for (int num=0;num<40;num++) {
if (!used_mask.test(num)) {
used_mask.set(num);
stand_mask[player].set(num);
Player pplayer = player;
/* 片玉しかない問題のため */
if (num==PtypeTraits<KING>::indexMin+playerToIndex(alt(player)))
{
pplayer=alt(player);
}
Piece p(pplayer,Piece_Table.getPtypeOf(num),num,Square::STAND());
setPieceOf(num,p);
}
}
}
// check
bool osl::SimpleState::isConsistent(bool show_error) const
{
// board上の要素のconsistency
for (int y=1;y<=9;y++)
{
for (int x=9;x>=1;x--)
{
const Square pos(x,y);
const Piece p0=pieceAt(pos);
if (p0.isPiece())
{
if (p0.square()!=pos)
{
if (show_error) {
std::cerr << p0 << " must be put at " << pos << std::endl;
}
return false;
}
int num=p0.number();
if (! PieceTable::validNumber(num) || !used_mask.test(num)) {
if (show_error) std::cerr << "NotUsed, num=" << num << std::endl;
return false;
}
Piece p1=pieceOf(num);
if (p0!=p1) {
if (show_error) std::cerr << "board[" << pos << "]!="
<< "piece[" << num << "]" << std::endl;
return false;
}
}
}
}
// piecesのconsistency
for (int num0=0; num0<Piece::SIZE; num0++)
{
if(!usedMask().test(num0)) continue;
if (isOnBoard(num0))
{
Piece p0=pieceOf(num0);
Ptype ptype=p0.ptype();
if (unpromote(ptype)!=Piece_Table.getPtypeOf(num0)) {
if (show_error) std::cerr << "ptype of piece[" << num0 << "]="
<< ptype << std::endl;
return false;
}
if (!p0.isOnBoard()) {
if (show_error) std::cerr << "mochigoma[" << num0 << "]=true" << std::endl;
return false;
}
Square pos=p0.square();
if (!pos.isOnBoard()) {
if (show_error) std::cerr << "position " << pos << " is not onboard" << std::endl;
return false;
}
Piece p1=pieceAt(pos);
int num1=p1.number();
if (num0 !=num1) {
if (show_error) std::cerr << "pieces[" << num0 << "]=" << p0 << ",board[" << pos << "] is " << p1 << std::endl;
return false;
}
}
else
{
Piece p0=pieceOf(num0);
Ptype ptype=p0.ptype();
#ifdef ALLOW_KING_ABSENCE
if (p0.isEmpty() && Piece_Table.getPtypeOf(num0) == KING)
continue;
#endif
if (p0.number()!=num0) {
if (show_error)
std::cerr << "pieces[" << num0 << "] ("
<< Piece_Table.getPtypeOf(num0) << ") ="
<< p0 << std::endl;
return false;
}
if (ptype!=Piece_Table.getPtypeOf(num0)) {
if (show_error) std::cerr << "ptype of piece[" << num0 << "]="
<< ptype << std::endl;
return false;
}
if (! p0.square().isPieceStand()) {
if (show_error) std::cerr << p0 << " must be offboard" << std::endl;
return false;
}
}
}
// mask
for (Ptype ptype: PieceStand::order) {
if (countPiecesOnStand(BLACK, ptype)
!= countPiecesOnStandBit(BLACK, ptype)) {
if (show_error) std::cerr << "count stand BLACK " << ptype << " inconsistent\n"
<< *this << countPiecesOnStand(BLACK, ptype)
<< " " << countPiecesOnStandBit(BLACK, ptype) << std::endl;
return false;
}
if (countPiecesOnStand(WHITE, ptype)
!= countPiecesOnStandBit(WHITE, ptype)) {
if (show_error) std::cerr << "count stand WHITE " << ptype << " inconsistent\n"
<< *this << countPiecesOnStand(WHITE, ptype)
<< " " << countPiecesOnStandBit(WHITE, ptype) << std::endl;
return false;
}
}
// pawnMask;
{
CArray<BitXmask,2> pawnMask1;
pawnMask1[0].clearAll();
pawnMask1[1].clearAll();
for (int num=PtypeTraits<PAWN>::indexMin;
num<PtypeTraits<PAWN>::indexLimit;num++){
if (isOnBoard(num)){
Piece p=pieceOf(num);
if (!p.isPromotedNotKingGold()){
pawnMask1[playerToIndex(p.owner())].set(p.square());
}
}
}
if ((pawnMask[0]!=pawnMask1[0])
|| (pawnMask[1]!=pawnMask1[1]))
{
if (show_error)
std::cerr << "pawnMask "
<< pawnMask[0] << "!=" << pawnMask1[0]
<< " || " << pawnMask[1] << "!=" << pawnMask1[1]
<< std::endl;
return false;
}
}
// illegal position for piece
for (int i=0; i<nthLimit<PAWN>(); ++i) {
const Piece pawn = nth<PAWN>(i);
if (! pawn.isPromoted() && pawn.isOnBoard()
&& pawn.square().squareForBlack(pawn.owner()).y() == 1) {
if (show_error)
std::cerr << "pawn " << pawn << std::endl;
return false;
}
}
for (int i=0; i<nthLimit<LANCE>(); ++i) {
const Piece lance = nth<LANCE>(i);
if (! lance.isPromoted() && lance.isOnBoard()
&& lance.square().squareForBlack(lance.owner()).y() == 1) {
if (show_error)
std::cerr << "lance " << lance << std::endl;
return false;
}
}
for (int i=0; i<nthLimit<KNIGHT>(); ++i) {
const Piece knight = nth<KNIGHT>(i);
if (! knight.isPromoted() && knight.isOnBoard()
&& knight.square().squareForBlack(knight.owner()).y() == 1) {
if (show_error)
std::cerr << "knight " << knight << std::endl;
return false;
}
}
return true;
}
bool osl::SimpleState::isAlmostValidMove(Move move,bool show_error) const
{
if (show_error)
{
const bool valid = isAlmostValidMove<true>(move);
if (! valid)
std::cerr << *this << " " << move << std::endl;
return valid;
}
else
return isAlmostValidMove<false>(move);
}
template <bool show_error>
bool osl::SimpleState::isAlmostValidMove(Move move) const
{
assert(move.isValid());
assert(turn() == move.player());
assert(isValidMoveByRule(move, true));
const Square from=move.from();
if (from.isPieceStand()) // 打つ手
return isAlmostValidDrop<show_error>(move);
const Square to=move.to();
if (! testValidityOtherThanEffect<show_error>(move))
return false;
const Piece from_piece = pieceAt(from);
// その offsetの動きがptypeに関してvalidか?
EffectContent effect=Ptype_Table.getEffect(from_piece.ptypeO(),from,to);
if (!effect.hasUnblockableEffect())
{
const Offset o=effect.offset();
if (o.zero()) {
if (show_error) {
std::cerr << " No such move2 : " << move << std::endl;
}
return false;
}
// 離れた動きの時に間が全部空いているか?
for (Square p=from+o;p!=to;p+=o) {
if (! pieceAt(p).isEmpty()) {
if (show_error)
std::cerr << " Not space to move : " << move << std::endl;
return false;
}
}
}
assert(isValidMoveByRule(move, true));
return true;
}
bool osl::SimpleState::isValidMoveByRule(Move move,bool show_error)
{
assert(move.isNormal());
const Square from=move.from();
const Square to=move.to();
const Ptype ptype=move.ptype();
const Player turn = move.player();
if (from.isPieceStand()) // 打つ手
{
// 動けない場所ではないか?
if (! Ptype_Table.canDropTo(turn,ptype,to))
{
if (show_error) std::cerr << " can't drop to : " << move << std::endl;
return false;
}
}
else
{
if (isBasic(move.ptype()) && move.isPromotion())
{
if (show_error) std::cerr << " inconsistent promote " << move << std::endl;
return false;
}
const PtypeO old_ptypeo = move.oldPtypeO();
const EffectContent effect
= Ptype_Table.getEffect(old_ptypeo, Offset32(to,from));
// その offsetの動きがptypeに関してvalidか?
if (!effect.hasUnblockableEffect())
{
const Offset o = effect.offset();
if (o.zero()) {
if (show_error) {
std::cerr << " No such move1 : " << move << std::endl;
}
return false;
}
}
// promoteしている時にpromote可能か
if (move.isPromotion())
{
if (! (canPromote(unpromote(move.ptype()))
&& (to.canPromote(move.player())
|| from.canPromote(move.player()))))
{
if (show_error)
std::cerr << " illegal promote type or position : " << move << std::endl;
return false;
}
}
// promoteしていない時に強制promoteでないか?
if ((! isPromoted(ptype)
&& ! Ptype_Table.canDropTo(turn,getPtype(old_ptypeo),to))
&& !move.isPromotion())
{
if (show_error)
std::cerr << " must promote to this position : " << move << std::endl;
return false;
}
}
return true;
}
bool osl::SimpleState::isValidMove(Move move,bool show_error) const
{
if (turn() != move.player()) {
if (show_error) {
std::cerr << "invalid player move : " << move << std::endl;
std::cerr << *this;
}
return false;
}
if (! isValidMoveByRule(move, show_error) || ! move.isValid())
return false;
return isAlmostValidMove(move, show_error);
}
#ifndef MINIMAL
bool osl::SimpleState::dump() const
{
return static_cast<bool>(std::cerr << *this << "\n");
}
#endif
const osl::SimpleState
osl::SimpleState::emulateCapture(Piece from, Player new_owner) const {
osl::SimpleState newState;
for(int i=0;i<40;i++){
Piece p=pieceOf(i);
if(p==from){
newState.setPiece(new_owner,Square::STAND(),unpromote(p.ptype()));
}
else{
newState.setPiece(p.owner(),p.square(),p.ptype());
}
}
newState.setTurn(turn());
newState.initPawnMask();
return newState;
}
const osl::SimpleState
osl::SimpleState::emulateHandPiece(Player from, Player to, Ptype ptype) const {
assert(hasPieceOnStand(from, ptype));
assert(from==alt(to));
osl::SimpleState newState;
bool done=false;
for(int i=0;i<40;i++){
if(!usedMask().test(i)) continue;
Piece p=pieceOf(i);
if(!done &&
p.owner()==from &&
!p.isOnBoard() &&
p.ptype()==ptype){
newState.setPiece(to,Square::STAND(),ptype);
done=true;
}
else{
newState.setPiece(p.owner(),p.square(),p.ptype());
}
}
assert(done);
newState.setTurn(turn());
newState.initPawnMask();
return newState;
}
const osl::SimpleState osl::SimpleState::rotate180() const
{
SimpleState ret;
for (int i=0; i<40; ++i) {
if(!usedMask().test(i)) continue;
const Piece p = pieceOf(i);
ret.setPiece(alt(p.owner()), p.square().rotate180Safe(), p.ptype());
}
ret.setTurn(alt(turn()));
ret.initPawnMask();
return ret;
}
const osl::SimpleState osl::SimpleState::flipHorizontal() const
{
SimpleState ret;
for (int i=0; i<40; ++i) {
if(!usedMask().test(i)) continue;
const Piece p = pieceOf(i);
ret.setPiece(p.owner(), p.square().flipHorizontal(), p.ptype());
}
ret.setTurn(turn());
ret.initPawnMask();
return ret;
}
bool osl::operator==(const SimpleState& st1,const SimpleState& st2)
{
assert(st1.isConsistent(false));
assert(st2.isConsistent(false));
if (st1.turn()!=st2.turn())
return false;
if (st1.pawnMask[0]!=st2.pawnMask[0]) return false;
if (st1.pawnMask[1]!=st2.pawnMask[1]) return false;
for (int y=1;y<=9;y++)
for (int x=9;x>0;x--) {
Piece p1=st1.pieceAt(Square(x,y));
Piece p2=st2.pieceAt(Square(x,y));
if (p1.ptypeO()!=p2.ptypeO()) return false;
}
return true;
}
namespace osl
{
namespace
{
void showStand(std::ostream& os, Player player, PieceStand stand)
{
if (! stand.any())
return;
os << "P" << csa::show(player);
for (Ptype ptype: PieceStand::order) {
for (unsigned int j=0; j<stand.get(ptype); ++j)
{
os << "00" << csa::show(ptype);
}
}
os << "\n";
}
} // anonymous namespace
} // namespace osl
std::ostream& osl::operator<<(std::ostream& os,const SimpleState& state)
{
for (int y=1;y<=9;y++) {
os << 'P' << y;
for (int x=9;x>0;x--) {
os << csa::show(state.pieceOnBoard(Square(x,y)));
}
os << std::endl;
}
// 持ち駒の表示
const PieceStand black_stand(BLACK, state);
const PieceStand white_stand(WHITE, state);
showStand(os, BLACK, black_stand);
showStand(os, WHITE, white_stand);
os << state.turn() << std::endl;
return os;
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
pieceStand.h
osl::CArray
Definition container.h:20
osl::EffectContent
Definition effectContent.h:11
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::isValid
bool isValid() const
Definition basic_type.cc:246
osl::Move::isPromotion
bool isPromotion() const
Definition basic_type.h:1147
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::Move::player
Player player() const
Definition basic_type.h:1195
osl::Move::oldPtypeO
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
Definition basic_type.h:1168
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::Move::from
const Square from() const
Definition basic_type.h:1125
osl::Offset
座標の差分
Definition basic_type.h:430
osl::Offset::zero
bool zero() const
Definition basic_type.h:502
osl::PieceStand
片方の手番の持駒の枚数を記録するクラス.
Definition bits/pieceStand.h:38
osl::PieceStand::order
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
Definition bits/pieceStand.h:41
osl::PieceTable::validNumber
static bool validNumber(int num)
Definition pieceTable.h:22
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptypeO
PtypeO ptypeO() const
Definition basic_type.h:824
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::Piece::isPromoted
bool isPromoted() const
promoteした駒かどうかをチェックする
Definition basic_type.h:898
osl::Piece::square
const Square square() const
Definition basic_type.h:832
osl::Piece::isEmpty
bool isEmpty() const
Definition basic_type.h:913
osl::Piece::owner
Player owner() const
Definition basic_type.h:963
osl::Piece::isPiece
bool isPiece() const
Definition basic_type.h:953
osl::Piece::number
int number() const
Definition basic_type.h:828
osl::Piece::isPromotedNotKingGold
bool isPromotedNotKingGold() const
Definition basic_type.h:908
osl::Piece::EMPTY
static const Piece EMPTY()
Definition basic_type.h:797
osl::Piece::isOnBoard
bool isOnBoard() const
Definition basic_type.h:985
osl::Piece::SIZE
static const int SIZE
Definition basic_type.h:794
osl::Piece::EDGE
static const Piece EDGE()
Definition basic_type.h:798
osl::SimpleState
Definition simpleState.h:35
osl::SimpleState::pawnMask
CArray< BitXmask, 2 > pawnMask
Definition simpleState.h:57
osl::SimpleState::pieceOnBoard
const Piece pieceOnBoard(Square sq) const
Definition simpleState.h:170
osl::SimpleState::isValidMove
bool isValidMove(Move move, bool show_error=true) const
合法手かどうかを検査する． isValidMoveByRule, isAlmostValidMove をおこなう． 玉の素抜きや王手を防いでいるか， 千日手，打歩詰かどうかは検査しない．
Definition simpleState.cc:435
osl::SimpleState::isAlmostValidDrop
bool isAlmostValidDrop(Move move) const
osl::SimpleState::player_to_move
Player player_to_move
手番
Definition simpleState.h:61
osl::SimpleState::hasPieceOnStand
bool hasPieceOnStand(Player player, Ptype ptype) const
Definition simpleState.h:191
osl::SimpleState::emulateHandPiece
const SimpleState emulateHandPiece(Player from, Player to, Ptype ptype) const
from からto に ptypeの持駒を一枚渡した局面を作る.
Definition simpleState.cc:480
osl::SimpleState::setTurn
void setTurn(Player player)
Definition simpleState.h:217
osl::SimpleState::nth
const Piece nth(int n) const
unpromote(PTYPE)のn番目の駒を帰す.
Definition simpleState.h:114
osl::SimpleState::isValidMoveByRule
static bool isValidMoveByRule(Move move, bool show_error)
盤面以外の部分の反則のチェック
Definition simpleState.cc:372
osl::SimpleState::stand_count
CArray< CArray< char, PTYPE_SIZE-PTYPE_BASIC_MIN >, 2 > stand_count
Definition simpleState.h:58
osl::SimpleState::used_mask
PieceMask used_mask
Definition simpleState.h:62
osl::SimpleState::setPieceOf
void setPieceOf(int num, Piece p)
Definition simpleState.h:79
osl::SimpleState::init
void init()
盤面が空の状態に初期化
Definition simpleState.cc:44
osl::SimpleState::SimpleState
SimpleState()
Definition simpleState.cc:12
osl::SimpleState::isOnBoard
bool isOnBoard(int num) const
Definition simpleState.h:176
osl::SimpleState::turn
Player turn() const
Definition simpleState.h:220
osl::SimpleState::emulateCapture
const SimpleState emulateCapture(Piece from, Player new_owner) const
from で表現されたPieceをnew_ownerの持駒にした局面を作る.
Definition simpleState.cc:460
osl::SimpleState::setPieceAll
void setPieceAll(Player player)
Definition simpleState.cc:139
osl::SimpleState::~SimpleState
virtual ~SimpleState()
Definition simpleState.cc:112
osl::SimpleState::initPawnMask
void initPawnMask()
Definition simpleState.cc:20
osl::SimpleState::stand_mask
CArray< PieceMask, 2 > stand_mask
Definition simpleState.h:56
osl::SimpleState::setBoard
void setBoard(Square sq, Piece piece)
Definition simpleState.h:119
osl::SimpleState::pieces
CArray< Piece, Piece::SIZE > pieces
全てのpieceが登録されている
Definition simpleState.h:55
osl::SimpleState::usedMask
const PieceMask & usedMask() const
Definition simpleState.h:131
osl::SimpleState::testValidityOtherThanEffect
bool testValidityOtherThanEffect(Move move) const
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition simpleState.h:76
osl::SimpleState::isConsistent
bool isConsistent(bool show_error=true) const
Definition simpleState.cc:157
osl::SimpleState::flipHorizontal
const SimpleState flipHorizontal() const
Definition simpleState.cc:518
osl::SimpleState::countPiecesOnStandBit
int countPiecesOnStandBit(Player pl, Ptype ptype) const
Definition simpleState.h:199
osl::SimpleState::setPiece
void setPiece(Player player, Square sq, Ptype ptype)
Definition simpleState.cc:114
osl::SimpleState::isPawnMaskSet
bool isPawnMaskSet(Player player, int x) const
Definition simpleState.h:146
osl::SimpleState::countPiecesOnStand
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
Definition simpleState.h:182
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::SimpleState::rotate180
const SimpleState rotate180() const
Definition simpleState.cc:505
osl::SimpleState::isAlmostValidMove
bool isAlmostValidMove(Move move) const
エラー表示をするかどうかをtemplateパラメータにした高速化版
Definition simpleState.cc:332
osl::SimpleState::dump
bool dump() const
dump: 自分を cerr に表示する。abort 前などにデバッグに使う
Definition simpleState.cc:450
osl::Square
Definition basic_type.h:532
osl::Square::isPieceStand
bool isPieceStand() const
Definition basic_type.h:576
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::canPromote
bool canPromote() const
Definition basic_type.h:659
osl::Square::squareForBlack
const Square squareForBlack(Player player) const
Definition basic_type.h:598
osl::Square::STAND
static const Square STAND()
Definition basic_type.h:548
osl::Square::SIZE
@ SIZE
Definition basic_type.h:543
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定． 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する．
Definition basic_type.h:583
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
osl::Square::rotate180Safe
const Square rotate180Safe() const
Definition basic_type.h:622
osl::Square::flipHorizontal
const Square flipHorizontal() const
Definition basic_type.h:628
osl::Square::nth
static const Square nth(unsigned int i)
Definition basic_type.h:559
csa.h
osl::csa::show
const std::string show(Move)
Definition csa.cc:133
osl::effect
Definition effectedNumTable.h:8
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::ROOK
@ ROOK
Definition basic_type.h:100
osl::BISHOP
@ BISHOP
Definition basic_type.h:99
osl::PAWN
@ PAWN
Definition basic_type.h:95
osl::KING
@ KING
Definition basic_type.h:93
osl::KNIGHT
@ KNIGHT
Definition basic_type.h:97
osl::SILVER
@ SILVER
Definition basic_type.h:98
osl::PTYPE_BASIC_MIN
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
osl::GOLD
@ GOLD
Definition basic_type.h:94
osl::LANCE
@ LANCE
Definition basic_type.h:96
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition tables.cc:97
osl::getPtype
Ptype getPtype(PtypeO ptypeO)
Definition basic_type.h:217
osl::Piece_Table
const PieceTable Piece_Table
Definition tables.cc:94
osl::canPromote
bool canPromote(Ptype ptype)
ptypeがpromote可能な型かどうかのチェック promote済みの場合はfalseを返す
Definition basic_type.h:147
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
osl::playerToIndex
constexpr int playerToIndex(Player player)
Definition basic_type.h:16
osl::isPromoted
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
Definition basic_type.h:137
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition offset32.h:63
osl::Player
Player
Definition basic_type.h:8
osl::WHITE
@ WHITE
Definition basic_type.h:10
osl::BLACK
@ BLACK
Definition basic_type.h:9
osl::Handicap
Handicap
Definition simpleState.h:20
osl::HIRATE
@ HIRATE
Definition simpleState.h:21
osl::PtypeO
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition basic_type.h:199
osl::isBasic
bool isBasic(Ptype ptype)
ptypeが基本型(promoteしていない)かのチェック
Definition basic_type.h:128
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
osl::operator<<
std::ostream & operator<<(std::ostream &os, Player player)
Definition basic_type.cc:14
osl::operator==
bool operator==(Square l, Square r)
Definition basic_type.h:758
pieceTable.h
simpleState.h
simpleState.tcc
osl::PtypeTraits
Definition ptypeTraits.h:12
osl::csa::CsaIOError
Definition csa.h:18