16 osl::checkmate::Proof_Number_Table.
init();
17 osl::checkmate::Edge_Table.
init();
30 const checkmate::ProofNumberTable::Liberty
36 return ProofNumberTable::Liberty(0,
false);
44 for (
int l=0;l<8;l++) {
51 if ((dx != dx1 || dy != dy1)
55 return ProofNumberTable::Liberty(
std::max(count,1), has_effect);
57 const checkmate::ProofNumberTable::Liberty
68 for (
int l=0;l<8;l++) {
78 return ProofNumberTable::Liberty(
std::max(count,1), has_effect);
87 for (
int i=0; i<0x100; i++) {
91 for (
int j=0; j<8; j++) {
93 const Liberty e = effectiveCheckShort(ptype,dir,i);
94 liberties[i][k][j] = e;
99 const Liberty e = effectiveCheckLong(ptype,dir,i);
100 liberties[i][k][j] = e;
106 drop_liberty.fill(0);
107 for(
int i=0;i<0x10000;i++){
108 const unsigned int liberty = (i>>8)&0xff;
109 const int liberty_count = misc::BitOp::countBit(liberty);
110 if (liberty_count <= 2)
114 int minimum_liberty = liberty_count;
118 for (
int j=0;j<8;j++) {
122 if ((i&(0x100<<j))!=0)
126 const bool has_effect
131 const int e = liberties[liberty][k][j].liberty;
133 minimum_liberty =
std::min(minimum_liberty, e);
135 for (
int l=minimum_liberty; l<liberty_count; ++l)
137 drop_liberty[i][l] |= (1<<(ptype-
GOLD));
142 pmajor_liberty.fill(8);
143 for (
int l=0; l<0x100; l++) {
144 for (
int m=0; m<0x100; m++) {
147 int min_liberty =
std::max(2,misc::BitOp::countBit(l))-1;
150 for (
int j=0; j<8; j++) {
153 const int pr = liberties[l][
PROOK][j].liberty;
154 const int pb = liberties[l][
PBISHOP][j].liberty;
159 pmajor_liberty[l][m] = min_liberty;
163 promote_liberty.fill(8);
164 for (
int l=0; l<0x100; l++) {
165 for (
int m=0; m<0x100; m++) {
168 int min_liberty =
std::max(2,misc::BitOp::countBit(l))-1;
171 for (
int j=0; j<8; j++) {
178 Liberty e = liberties[l][k][j];
187 promote_liberty[l][m] = min_liberty;
191 other_move_liberty.fill(8);
192 for (
int l=0; l<0x100; l++) {
193 for (
int m=0; m<0x100; m++) {
196 int min_liberty =
std::max(2,misc::BitOp::countBit(l))-1;
199 for (
int j=0; j<8; j++) {
210 Liberty e = liberties[l][k][j];
219 other_move_liberty[l][m] = min_liberty;
230 return countLiberty(state, info.libertyCount(), move, king, info);
237 assert(state.
turn() == attack);
242 uint8_t ptype_mask = 0;
247 && (ptype_mask & drop_liberty[ld_mask][result-1]);
259 return libertyAfterAllDrop(state, attack, info);
267 bool has_pmajor =
false;
270 i < PtypeTraits<ROOK>::indexLimit; i++)
283 if (Neighboring8Direct::hasEffect(state, p.
ptypeO(), p.
square(),
299 int result = pmajor_liberty[info.
liberty()][moveCandidate];
311 int result = promote_liberty[info.
liberty()][moveCandidate];
315 int result = other_move_liberty[info.
liberty()][moveCandidate];
326 return libertyAfterAllMove(state, attack, info, king);
339 num_checks += misc::BitOp::countBit(info.
dropCandidate()) * drop_scale;
348 int p = libertyAfterAllDrop(state, attack, info);
351 p =
std::min(p, libertyAfterAllMove(state, attack, info, king));
353 return ProofDisproof(p, disproofAfterAllCheck(state, attack, info));
362 return attackEstimation(state, attack, info, king);
368 return attackEstimation(state).proof();
375 edge_mask.fill(~(0xfull << 48));
376 for (
int x=1; x<=9; ++x) {
377 for (
int y=1; y<=9; ++y) {
381 if (target.
x() <= 1 || target.
x() >= 9 || target.
y() <=1 || target.
y() >=9)
382 edge_mask[
BLACK][king.
index()] &= ~(0x100ull<<d);
384 if (target.
x() <= 1 || target.
x() >= 9 || target.
y() <=1 || target.
y() >=9)
385 edge_mask[
WHITE][king.
index()] &= ~(0x100ull<<d);
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
int max(Player p, int v1, int v2)
const Liberty countLiberty(Ptype ptype, Direction d, unsigned int liberty_mask) const
dir 方向からの王手をかけた時のlibertyの予想
bool isMajor(Ptype ptype)
constexpr int dirToMask(Direction dir)
constexpr bool isShort(Direction d)
constexpr Player alt(Player player)
int getMoveMask(Ptype ptype) const
int min(Player p, int v1, int v2)
bool hasEffectByPtype(Player attack, Square target) const
target に ptype の利きがあるか? 成不成を区別しない
bool hasEffect() const
短い利きがあるか,間がemptyなら長い利きがある
int y() const
将棋としてのY座標を返す.
static osl::SetUpRegister _initializer([](){ osl::Centering3x3::table.init();})
int x() const
将棋としてのX座標を返す.
Offset32Base< 8, 9 > Offset32
unsigned int moveCandidateMask(NumEffectState const &state) const
PtypeO newPtypeO(Player player, Ptype ptype)
const Piece pieceOf(int num) const
Square kingSquare() const
const PtypeTable Ptype_Table
unsigned int countMoveCandidate(NumEffectState const &state) const
bool hasPieceOnStand(Player player, Ptype ptype) const
bool has_effect
false の場合は必ず空き王手
const EffectContent getEffect(PtypeO ptypeo, Square from, Square to) const
fromにいるptypeoがtoに利きを持つか?
constexpr Direction shortToLong(Direction d)
引数に longDirを与えてはいけない
unsigned int dropCandidate() const
0-7 bit 目を返す
int libertyAfterAllCheck(const NumEffectState &state) const
全て
unsigned int index() const
int libertyAfterAllDrop(const NumEffectState &state) const
drop のみ
unsigned int libertyDropMask() const
0-15bit
unsigned int liberty() const
8-15 bit 目を 0-7bitにshiftして返す
uint64_t Iking8Info(Player king) const
const Square square() const
const ProofDisproof attackEstimation(const NumEffectState &state) const
全て
int getDxForBlack(Direction dir) const
証明数(proof number)と反証数(disproof number).
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
int libertyAfterAllMove(const NumEffectState &state) const
移動 のみ
constexpr bool isLong(Direction d)
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
int getDyForBlack(Direction dir) const
ProofNumberTable Proof_Number_Table
int disproofAfterAllCheck(const NumEffectState &, Player, King8Info) const
const Square squareForBlack(Player player) const
const Offset getOffset(Direction dir) const
uint8_t liberty
玉の自由度の予測値.
unsigned int libertyCount() const
libertyの数
const BoardTable Board_Table