3#ifndef OSL_PIECESTAND_H
4#define OSL_PIECESTAND_H
53 int knightCount,
int silverCount,
54 int goldCount,
int bishopCount,
55 int rookCount,
int kingCount)
71 assert(num == (num &
mask[type]));
78 assert(num == (num &
mask[type]));
79 assert(
get(type) >= num);
161 return hasMoreThan<BLACK>(other);
163 return hasMoreThan<WHITE>(other);
176 unsigned int my_mask = mask0-((mask0&0x40000024)>>2);
178 my_mask -= (mask0&0x08022200)>>3;
180 my_mask -= (mask0&0x00800000)>>5;
191 const unsigned int mask0=diff0&
carryMask;
194 const unsigned int mask02=(mask0&0x40000024u)+(mask0&0x48022224u);
195 unsigned int my_mask=mask0-(mask02>>3);
198 my_mask -= (mask0&0x00800000)>>5;
268 std::ostream&
operator<<(std::ostream&, PieceStand l);
Ptype capturePtype() const
bool isNormal() const
INVALID でも PASS でもない.
static const CArray< unsigned char, PTYPE_MAX+1 > shift
bool hasMoreThan(Player P, PieceStand other) const
void add(Ptype type, unsigned int num=1)
static const unsigned int carryMask
unsigned int testCarries() const
const PieceStand nextStand(Player pl, Move move) const
void tryAdd(Ptype type)
加算可能なら加える.
static const CArray< unsigned char, PTYPE_MAX+1 > mask
void trySub(Ptype type)
1枚以上持っていれば減らす
void subAtmostOnePiece(PieceStand const &ps)
bool isSuperiorOrEqualTo(PieceStand other) const
const PieceStand max(PieceStand other) const
種類毎に this と other の持駒の多い方を取る
bool any() const
どれかの駒を一枚でも持っている
bool canAdd(Ptype type) const
bool hasMoreThan(PieceStand other) const
this と other が BLACK の持駒と考えた時に, this の方が同じか沢山持っていれば真.
PieceStand(unsigned int value=0)
const PieceStand previousStand(Move move) const
bool carryUnchangedAfterSub(const PieceStand &original, const PieceStand &other) const
const PieceStand previousStand(Player pl, Move move) const
bool carryUnchangedAfterAdd(const PieceStand &original, const PieceStand &other) const
bool atMostOneKind() const
一種類の駒しかない
const PieceStand nextStand(Move move) const
unsigned int getFlags() const
unsigned int get(Ptype type) const
void addAtmostOnePiece(PieceStand const &ps)
pieceStand同士の加算,減算.
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
void sub(Ptype type, unsigned int num=1)
const PieceStand max2(PieceStand other) const
種類毎に this と other の持駒の多い方を取る (max のalternative)
PieceStand(int pawnCount, int lanceCount, int knightCount, int silverCount, int goldCount, int bishopCount, int rookCount, int kingCount)
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
bool operator<(Offset l, Offset r)
bool operator!=(Offset l, Offset r)
bool isBasic(Ptype ptype)
ptypeが基本型(promoteしていない)かのチェック
std::ostream & operator<<(std::ostream &os, Player player)
bool operator==(Square l, Square r)
static std::ostream & writeNumbers(std::ostream &, const PieceStand &stand)
持駒の数を空白区切で出力する.
static std::istream & readNumbers(std::istream &, PieceStand &stand)