My Project
proofPieces.h
Go to the documentation of this file.
1 /* proofPieces.h
2  */
3 #ifndef _PROOFPIECES_H
4 #define _PROOFPIECES_H
5 
7 namespace osl
8 {
9  namespace checkmate
10  {
11  class CheckMoveList;
12  struct ProofPieces
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:
osl::PieceStand::trySub
void trySub(Ptype type)
1枚以上持っていれば減らす
Definition: bits/pieceStand.h:92
osl::checkmate::ProofPieces::leaf
static const PieceStand leaf(const NumEffectState &state, Player attacker, const PieceStand max)
Definition: proofPieces.h:14
osl::alt
constexpr Player alt(Player player)
Definition: basic_type.h:13
osl::Move::isValid
bool isValid() const
Definition: basic_type.cc:246
osl::Move
圧縮していない moveの表現 .
Definition: basic_type.h:1052
osl::checkmate::ProofPieces::attack
static const PieceStand attack(const PieceStand prev, Move move, const PieceStand max)
Definition: proofPieces.h:24
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::eval::max
int max(Player p, int v1, int v2)
Definition: evalTraits.h:84
osl::checkmate::ProofPieces::defense
static const PieceStand defense(const CheckMoveList &moves, const NumEffectState &state, PieceStand max)
checkmate
osl::checkmate::ProofPieces
Definition: proofPieces.h:13
osl::Move::capturePtype
Ptype capturePtype() const
Definition: basic_type.h:1180
osl::Move::isDrop
bool isDrop() const
Definition: basic_type.h:1150
osl::PieceStand
片方の手番の持駒の枚数を記録するクラス.
Definition: bits/pieceStand.h:38
osl::PieceStand::add
void add(Ptype type, unsigned int num=1)
Definition: bits/pieceStand.h:68
osl::captured
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
Definition: basic_type.h:264
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
osl::NumEffectState::inUnblockableCheck
bool inUnblockableCheck(Player target) const
target の王に合駒可能でない王手がかかっているかどうか.
Definition: numEffectState.h:107
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::isPiece
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
Definition: basic_type.h:120
osl::Move::ptype
Ptype ptype() const
Definition: basic_type.h:1155
osl::SimpleState::turn
Player turn() const
Definition: simpleState.h:220
osl::Player
Player
Definition: basic_type.h:8
osl::PieceStand::get
unsigned int get(Ptype type) const
Definition: bits/pieceStand.h:131
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition: basic_type.h:157
osl
Definition: additionalEffect.h:6
proofPiecesUtil.h