My Project
proofPieces.h
Go to the documentation of this file.
1/* proofPieces.h
2 */
3#ifndef _PROOFPIECES_H
4#define _PROOFPIECES_H
5
7namespace osl
8{
9 namespace checkmate
10 {
11 class CheckMoveList;
13 {
14 static const PieceStand leaf(const NumEffectState& state,
15 Player attacker, const PieceStand max)
16 {
17 assert(state.turn() != attacker);
18 PieceStand result;
19 if (! state.inUnblockableCheck(alt(attacker)))
20 ProofPiecesUtil::addMonopolizedPieces(state, attacker, max, result);
21 return result;
22 }
23 static const PieceStand
24 attack(const PieceStand prev, Move move, const PieceStand max)
25 {
26 assert(move.isValid());
27 PieceStand result = prev;
28 if (move.isDrop())
29 {
30 const Ptype ptype = move.ptype();
31 if (result.get(ptype) < max.get(ptype))
32 result.add(ptype);
33 }
34 else
35 {
36 const Ptype captured = move.capturePtype();
37 if (isPiece(captured))
38 {
39 const Ptype ptype = unpromote(captured);
40 result.trySub(ptype);
41 }
42 }
43 return result;
44 }
45 static const PieceStand
46 defense(const CheckMoveList& moves, const NumEffectState& state,
47 PieceStand max);
48 };
49
50 } // namespace checkmate
51} // osl
52
53#endif /* _PROOFPIECES_H */
54// ;;; Local Variables:
55// ;;; mode:c++
56// ;;; c-basic-offset:2
57// ;;; End:
圧縮していない moveの表現 .
bool isValid() const
Ptype ptype() const
bool isDrop() const
Ptype capturePtype() const
利きを持つ局面
bool inUnblockableCheck(Player target) const
target の王に合駒可能でない王手がかかっているかどうか.
片方の手番の持駒の枚数を記録するクラス.
void add(Ptype type, unsigned int num=1)
void trySub(Ptype type)
1枚以上持っていれば減らす
unsigned int get(Ptype type) const
Player turn() const
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition basic_type.h:157
Player
Definition basic_type.h:8
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
Definition basic_type.h:120
constexpr Player alt(Player player)
Definition basic_type.h:13
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
Definition basic_type.h:264
static void addMonopolizedPieces(const SimpleState &state, Player player, const PieceStand max, PieceStand &out)
alt(player) が持っていない種類の持駒を playerが持っていたら out に独占分を加算する.
static const PieceStand leaf(const NumEffectState &state, Player attacker, const PieceStand max)
Definition proofPieces.h:14
static const PieceStand attack(const PieceStand prev, Move move, const PieceStand max)
Definition proofPieces.h:24
static const PieceStand defense(const CheckMoveList &moves, const NumEffectState &state, PieceStand max)