My Project
proofPiecesUtil.h
Go to the documentation of this file.
1/* proofPiecesUtil.h
2 */
3#ifndef OSL_PROOFPIECESUTIL_H
4#define OSL_PROOFPIECESUTIL_H
5
7
8namespace osl
9{
10 namespace checkmate
11 {
12 class CheckMoveList;
17 {
22 static
23 void addMonopolizedPieces(const SimpleState& state, Player player,
24 const PieceStand max, PieceStand& out)
25 {
26 const Player opponent = alt(player);
27 for (Ptype ptype: PieceStand::order)
28 {
29 if (! state.hasPieceOnStand(opponent, ptype))
30 {
31 const int diff = max.get(ptype) - out.get(ptype);
32 assert(diff >= 0);
33 if (diff)
34 out.add(ptype, diff);
35 }
36 }
37 }
38 };
39 } // namespace checkmate
40} // osl
41
42#endif /* OSL_PROOFPIECESUTIL_H */
43// ;;; Local Variables:
44// ;;; mode:c++
45// ;;; c-basic-offset:2
46// ;;; End:
片方の手番の持駒の枚数を記録するクラス.
void add(Ptype type, unsigned int num=1)
unsigned int get(Ptype type) const
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
bool hasPieceOnStand(Player player, Ptype ptype) const
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
Player
Definition basic_type.h:8
constexpr Player alt(Player player)
Definition basic_type.h:13
ProofPieces と DisproofPieces に共通の関数
static void addMonopolizedPieces(const SimpleState &state, Player player, const PieceStand max, PieceStand &out)
alt(player) が持っていない種類の持駒を playerが持っていたら out に独占分を加算する.