proofPieces.h
Go to the documentation of this file.
/* proofPieces.h
*/
#ifndef _PROOFPIECES_H
#define _PROOFPIECES_H
#include "osl/checkmate/proofPiecesUtil.h"
namespace osl
{
namespace checkmate
{
class CheckMoveList;
struct ProofPieces
{
static const PieceStand leaf(const NumEffectState& state,
Player attacker, const PieceStand max)
{
assert(state.turn() != attacker);
PieceStand result;
if (! state.inUnblockableCheck(alt(attacker)))
ProofPiecesUtil::addMonopolizedPieces(state, attacker, max, result);
return result;
}
static const PieceStand
attack(const PieceStand prev, Move move, const PieceStand max)
{
assert(move.isValid());
PieceStand result = prev;
if (move.isDrop())
{
const Ptype ptype = move.ptype();
if (result.get(ptype) < max.get(ptype))
result.add(ptype);
}
else
{
const Ptype captured = move.capturePtype();
if (isPiece(captured))
{
const Ptype ptype = unpromote(captured);
result.trySub(ptype);
}
}
return result;
}
static const PieceStand
defense(const CheckMoveList& moves, const NumEffectState& state,
PieceStand max);
};
} // namespace checkmate
} // osl
#endif /* _PROOFPIECES_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::isValid
bool isValid() const
Definition basic_type.cc:246
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::Move::isDrop
bool isDrop() const
Definition basic_type.h:1150
osl::Move::capturePtype
Ptype capturePtype() const
Definition basic_type.h:1180
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::inUnblockableCheck
bool inUnblockableCheck(Player target) const
target の王に合駒可能でない王手がかかっているかどうか.
Definition numEffectState.h:107
osl::PieceStand
片方の手番の持駒の枚数を記録するクラス.
Definition bits/pieceStand.h:38
osl::PieceStand::add
void add(Ptype type, unsigned int num=1)
Definition bits/pieceStand.h:68
osl::PieceStand::trySub
void trySub(Ptype type)
1枚以上持っていれば減らす
Definition bits/pieceStand.h:92
osl::PieceStand::get
unsigned int get(Ptype type) const
Definition bits/pieceStand.h:131
osl::SimpleState::turn
Player turn() const
Definition simpleState.h:220
osl::checkmate
Definition king8Info.h:12
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
osl::Player
Player
Definition basic_type.h:8
osl::isPiece
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
Definition basic_type.h:120
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
osl::captured
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に，ownerを反転する．
Definition basic_type.h:264
proofPiecesUtil.h
osl::checkmate::ProofPiecesUtil::addMonopolizedPieces
static void addMonopolizedPieces(const SimpleState &state, Player player, const PieceStand max, PieceStand &out)
alt(player) が持っていない種類の持駒を playerが持っていたら out に独占分を加算する．
Definition proofPiecesUtil.h:23
osl::checkmate::ProofPieces
Definition proofPieces.h:13
osl::checkmate::ProofPieces::leaf
static const PieceStand leaf(const NumEffectState &state, Player attacker, const PieceStand max)
Definition proofPieces.h:14
osl::checkmate::ProofPieces::attack
static const PieceStand attack(const PieceStand prev, Move move, const PieceStand max)
Definition proofPieces.h:24
osl::checkmate::ProofPieces::defense
static const PieceStand defense(const CheckMoveList &moves, const NumEffectState &state, PieceStand max)