3#ifndef OSL_CHECKMATE_KING8INFO_H
4#define OSL_CHECKMATE_KING8INFO_H
51 return (
unsigned int)(
value&0xffull);
56 return (
unsigned int)((
value>>8)&0xffull);
61 return (
unsigned int)(
value&0xffffull);
66 return (
unsigned int)((
value>>16)&0xffull);
71 return (
unsigned int)((
value>>24)&0xffull);
75 return (
unsigned int)((
value>>32)&0xffull);
79 return (
unsigned int)((
value>>40)&0xffull);
84 return (
unsigned int)((
value>>48)&0xfull);
86 template<Player P,Direction Dir>
88 if((
value & (1ull<<(24+Dir)))==0)
return 0;
99 return moveCandidateDir<P,UL>(state,king)+
100 moveCandidateDir<P,U>(state,king)+
101 moveCandidateDir<P,UR>(state,king)+
102 moveCandidateDir<P,L>(state,king)+
103 moveCandidateDir<P,R>(state,king)+
104 moveCandidateDir<P,DL>(state,king)+
105 moveCandidateDir<P,D>(state,king)+
106 moveCandidateDir<P,DR>(state,king);
110 if(player==
BLACK)
return countMoveCandidate<BLACK>(state);
111 else return countMoveCandidate<WHITE>(state);
118 return (moveCandidateDir<P,UL>(state,king)<<
UL)+
119 (moveCandidateDir<P,U>(state,king)<<
U)+
120 (moveCandidateDir<P,UR>(state,king)<<
UR)+
121 (moveCandidateDir<P,L>(state,king)<<
L)+
122 (moveCandidateDir<P,R>(state,king)<<
R)+
123 (moveCandidateDir<P,DL>(state,king)<<
DL)+
124 (moveCandidateDir<P,D>(state,king)<<
D)+
125 (moveCandidateDir<P,DR>(state,king)<<
DR);
132 if(moveCandidateDir<P,U>(state,king)!=0)
return true;
133 if(moveCandidateDir<P,UL>(state,king)!=0)
return true;
134 if(moveCandidateDir<P,UR>(state,king)!=0)
return true;
135 if(moveCandidateDir<P,L>(state,king)!=0)
return true;
136 if(moveCandidateDir<P,R>(state,king)!=0)
return true;
137 if(moveCandidateDir<P,D>(state,king)!=0)
return true;
138 if(moveCandidateDir<P,DL>(state,king)!=0)
return true;
139 if(moveCandidateDir<P,DR>(state,king)!=0)
return true;
150 template<Player P,Direction Dir>
161 using checkmate::King8Info;
int countEffect(Player player, Square target) const
利きの数を数える.
Square kingSquare() const
uint64_t uint64Value() const
static const King8Info make(NumEffectState const &state, Square king)
unsigned int libertyCandidate() const
16-23 bit 目を 0-7bitにshiftして返す
unsigned int liberty() const
8-15 bit 目を 0-7bitにshiftして返す
unsigned int countMoveCandidate(NumEffectState const &state) const
unsigned int moveCandidate2() const
24-31 bit 目を 0-7bitにshiftして返す
static const King8Info makeWithPin(Player attack, NumEffectState const &state, const PieceMask &pinned)
alt(attack) のking について計算.
unsigned int moveCandidateMask(NumEffectState const &state) const
unsigned int libertyDropMask() const
0-15bit
unsigned int dropCandidate() const
0-7 bit 目を返す
bool hasMoveCandidate(NumEffectState const &state) const
static const King8Info make(NumEffectState const &state, Square king, PieceMask pinned)
unsigned int libertyCount() const
libertyの数
unsigned int moves() const
static uint64_t hasEffectMask(NumEffectState const &state, Square target, PieceMask pinned, PieceMask on_board_defense)
alt(P)の玉にDirの方向で迫るcanMoveMaskを計算する.
unsigned int countMoveCandidate(Player player, NumEffectState const &state) const
unsigned int moveCandidateDir(NumEffectState const &state, Square target) const
unsigned int spaces() const
std::ostream & operator<<(std::ostream &, King8Info)
const PtypeO PTYPEO_EDGE __attribute__((unused))
constexpr Player alt(Player player)
static bool hasEffect(const NumEffectState &, Square target, Player attack)
target に attack の追加利きが一つでもあるか. 相手の影利きが先にある場合は対象としない.