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]));
72 flags += (num << (shift[type]));
78 assert(num == (num & mask[type]));
79 assert(
get(type) >= num);
80 flags -= (num << (shift[type]));
133 return (flags >> (shift[type])) & mask[type];
142 const bool result = (((flags - other.
flags) & carryMask) ==
carryMask);
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;
275 static std::ostream& writeNumbers(std::ostream&,
const PieceStand& stand);
276 static std::istream& readNumbers(std::istream&,
PieceStand& stand);
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す ...
bool isSuperiorOrEqualTo(PieceStand other) const
void add(Ptype type, unsigned int num=1)
PieceStand(int pawnCount, int lanceCount, int knightCount, int silverCount, int goldCount, int bishopCount, int rookCount, int kingCount)
static const CArray< unsigned char, PTYPE_MAX+1 > shift
bool isNormal() const
INVALID でも PASS でもない.
std::ostream & operator<<(std::ostream &os, Player player)
const PieceStand nextStand(Player pl, Move move) const
bool atMostOneKind() const
一種類の駒しかない
unsigned int testCarries() const
static const CArray< unsigned char, PTYPE_MAX+1 > mask
void subAtmostOnePiece(PieceStand const &ps)
bool isBasic(Ptype ptype)
ptypeが基本型(promoteしていない)かのチェック
const PieceStand previousStand(Move move) const
const PieceStand previousStand(Player pl, Move move) const
bool hasMoreThan(Player P, PieceStand other) const
bool operator<(Offset l, Offset r)
bool canAdd(Ptype type) const
bool carryUnchangedAfterSub(const PieceStand &original, const PieceStand &other) const
unsigned int getFlags() const
void tryAdd(Ptype type)
加算可能なら加える.
bool hasMoreThan(PieceStand other) const
this と other が BLACK の持駒と考えた時に, this の方が同じか沢山持っていれば真.
Ptype capturePtype() const
bool any() const
どれかの駒を一枚でも持っている
static const unsigned int carryMask
void trySub(Ptype type)
1枚以上持っていれば減らす
const PieceStand max2(PieceStand other) const
種類毎に this と other の持駒の多い方を取る (max のalternative)
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
bool carryUnchangedAfterAdd(const PieceStand &original, const PieceStand &other) const
void sub(Ptype type, unsigned int num=1)
const PieceStand max(PieceStand other) const
種類毎に this と other の持駒の多い方を取る
bool operator==(Square l, Square r)
bool operator!=(Offset l, Offset r)
void addAtmostOnePiece(PieceStand const &ps)
pieceStand同士の加算,減算.
const PieceStand nextStand(Move move) const
PieceStand(unsigned int value=0)