My Project
disproofPieces.h
Go to the documentation of this file.
1 /* disproofPieces.h
2  */
3 #ifndef _DISPROOFPIECES_H
4 #define _DISPROOFPIECES_H
5 
7 namespace osl
8 {
9  namespace checkmate
10  {
11  class CheckMoveList;
13  {
14  static const PieceStand leaf(const SimpleState& state, Player defender,
15  const PieceStand max)
16  {
17  assert(state.turn() != defender);
18  PieceStand result;
19  ProofPiecesUtil::addMonopolizedPieces(state, defender, max, result);
20  return result;
21  }
22  static const PieceStand
23  defense(const PieceStand prev, Move move, const PieceStand max)
24  {
25  assert(move.isValid());
26  PieceStand result = prev;
27  if (move.isDrop())
28  {
29  const Ptype ptype = move.ptype();
30  if (result.get(ptype) < max.get(ptype))
31  result.add(ptype);
32  }
33  else
34  {
35  const Ptype captured = move.capturePtype();
36  if (isPiece(captured))
37  {
38  const Ptype ptype = unpromote(captured);
39  result.trySub(ptype);
40  }
41  }
42  return result;
43  }
44  static const PieceStand
45  attack(const CheckMoveList& moves, const SimpleState& state,
46  PieceStand max);
47  };
48 
49  } // namespace checkmate
50 } // osl
51 
52 #endif /* _DISPROOFPIECES_H */
53 // ;;; Local Variables:
54 // ;;; mode:c++
55 // ;;; c-basic-offset:2
56 // ;;; End:
圧縮していない moveの表現 .
Definition: basic_type.h:1052
bool isValid() const
Definition: basic_type.cc:246
Ptype ptype() const
Definition: basic_type.h:1155
bool isDrop() const
Definition: basic_type.h:1150
Ptype capturePtype() const
Definition: basic_type.h:1180
片方の手番の持駒の枚数を記録するクラス.
void add(Ptype type, unsigned int num=1)
void trySub(Ptype type)
1枚以上持っていれば減らす
unsigned int get(Ptype type) const
Player turn() const
Definition: simpleState.h:220
int max(Player p, int v1, int v2)
Definition: evalTraits.h:84
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
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
Definition: basic_type.h:264
static const PieceStand leaf(const SimpleState &state, Player defender, const PieceStand max)
static const PieceStand defense(const PieceStand prev, Move move, const PieceStand max)
static const PieceStand attack(const CheckMoveList &moves, const SimpleState &state, PieceStand max)
static void addMonopolizedPieces(const SimpleState &state, Player player, const PieceStand max, PieceStand &out)
alt(player) が持っていない種類の持駒を playerが持っていたら out に独占分を加算する.