fixedDepthSolverExt.cc
Go to the documentation of this file.
#include "osl/checkmate/fixedDepthSolverExt.h"
#include "osl/checkmate/fixedDepthSearcher.tcc"
#include "osl/checkmate/proofPieces.h"
#include "osl/checkmate/proofNumberTable.h"
struct osl::checkmate::FixedDepthSolverExt::SetProofPieces
{
static void setAttackLeaf(Move best_move, PieceStand& proof_pieces) {
proof_pieces = PieceStand();
if (best_move.isDrop())
proof_pieces.add(best_move.ptype());
}
static void attack(Move best_move, PieceStand stand, PieceStand& proof_pieces) {
proof_pieces = ProofPieces::attack(proof_pieces, best_move, stand);
}
static void setLeaf(const NumEffectState& state, Player P, PieceStand stand, PieceStand& proof_pieces) {
proof_pieces = ProofPieces::leaf(state, P, stand);
}
static void clear(PieceStand& proof_pieces) {
proof_pieces = PieceStand();
}
static void updateMax(PieceStand child, PieceStand& proof_pieces) {
proof_pieces = proof_pieces.max(child);
}
static void addMonopolizedPieces(const NumEffectState& state, Player P,
PieceStand stand, PieceStand& proof_pieces) {
ProofPiecesUtil::addMonopolizedPieces(state, P, stand, proof_pieces);
}
static ProofDisproof attackEstimation(const NumEffectState& state, Player P, King8Info info) {
auto target_king = state.kingSquare(alt(P));
const King8Info info_modified
= Edge_Table.resetEdgeFromLiberty(alt(P), target_king, info);
return Proof_Number_Table.attackEstimation(state, P, info_modified, target_king);
}
};
osl::checkmate::FixedDepthSolverExt::FixedDepthSolverExt()
{
}
osl::checkmate::FixedDepthSolverExt::
FixedDepthSolverExt(NumEffectState& s) : FixedDepthSearcher(s)
{
}
template <osl::Player P>
const osl::checkmate::ProofDisproof
osl::checkmate::FixedDepthSolverExt::
hasEscapeByMove(Move next_move, int depth, Move& check_move,
PieceStand& proof_pieces)
{
typedef FixedDefenseHelper<P,SetProofPieces,true> helper_t;
proof_pieces = PieceStand();
ProofDisproof pdp;
helper_t helper(*this, depth+1, pdp, proof_pieces);
state->makeUnmakeMove(Player2Type<alt(P)>(),next_move,helper);
check_move = helper.best_move;
return pdp;
}
const osl::checkmate::ProofDisproof
osl::checkmate::FixedDepthSolverExt::
hasCheckmateMoveOfTurn(int depth, Move& best_move, PieceStand& proof_pieces)
{
if (state->turn() == BLACK)
return hasCheckmateMove<BLACK>(depth, best_move, proof_pieces);
else
return hasCheckmateMove<WHITE>(depth, best_move, proof_pieces);
}
const osl::checkmate::ProofDisproof
osl::checkmate::FixedDepthSolverExt::
hasCheckmateWithGuideOfTurn(int depth, Move& guide, PieceStand& proof_pieces)
{
if (state->turn() == BLACK)
return hasCheckmateWithGuide<BLACK>(depth, guide, proof_pieces);
else
return hasCheckmateWithGuide<WHITE>(depth, guide, proof_pieces);
}
const osl::checkmate::ProofDisproof
osl::checkmate::FixedDepthSolverExt::
hasEscapeByMoveOfTurn(Move next_move, int depth,
Move& check_move, PieceStand& proof_pieces)
{
if (state->turn() == BLACK)
return hasEscapeByMove<WHITE>(next_move, depth, check_move, proof_pieces);
else
return hasEscapeByMove<BLACK>(next_move, depth, check_move, proof_pieces);
}
template <osl::Player P>
const osl::checkmate::ProofDisproof
osl::checkmate::FixedDepthSolverExt::
hasCheckmateWithGuide(int depth, Move& guide, PieceStand& proof_pieces)
{
assert(guide.isNormal());
if (! guide.isDrop())
{
const Piece p=state->pieceOnBoard(guide.to());
if (!p.isPtype<KING>())
guide=guide.newCapture(p);
}
if (state->template isAlmostValidMove<false>(guide)
&& move_classifier::Check<P>
::isMember(*state, guide.ptype(), guide.from(), guide.to()))
return attack<P,SetProofPieces,true>(depth, guide, proof_pieces);
return attack<P,SetProofPieces,false>(depth, guide, proof_pieces);
}
template <osl::Player P>
const osl::checkmate::ProofDisproof osl::checkmate::
FixedDepthSolverExt::hasCheckmateMove(int depth, Move& best_move,
PieceStand& proof_pieces) {
return attack<P,SetProofPieces,false>(depth, best_move, proof_pieces);
}
template <osl::Player P>
const osl::checkmate::ProofDisproof osl::checkmate::
FixedDepthSolverExt::hasEscapeMove(Move last_move,int depth,
PieceStand& proof_pieces) {
return defense<P,SetProofPieces>(last_move, depth, proof_pieces);
}
namespace osl
{
template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasCheckmateMove<BLACK>(int, Move&, PieceStand&);
template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasCheckmateMove<WHITE>(int, Move&, PieceStand&);
template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeMove<BLACK>(Move, int, PieceStand&);
template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeMove<WHITE>(Move, int, PieceStand&);
template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeByMove<BLACK>(Move, int, Move&, PieceStand&);
template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeByMove<WHITE>(Move, int, Move&, PieceStand&);
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::Move::isDrop
bool isDrop() const
Definition basic_type.h:1150
osl::Move::newCapture
const Move newCapture(Piece capture) const
Definition basic_type.h:1231
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition basic_type.h:1088
osl::Move::to
const Square to() const
Definition basic_type.h:1132
osl::Move::from
const Square from() const
Definition basic_type.h:1125
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::PieceStand
片方の手番の持駒の枚数を記録するクラス.
Definition bits/pieceStand.h:38
osl::PieceStand::add
void add(Ptype type, unsigned int num=1)
Definition bits/pieceStand.h:68
osl::PieceStand::max
const PieceStand max(PieceStand other) const
種類毎に this と other の持駒の多い方を取る
Definition bits/pieceStand.h:171
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::isPtype
bool isPtype() const
Definition basic_type.h:930
osl::checkmate::FixedDepthSearcher::state
NumEffectState * state
Definition fixedDepthSearcher.h:43
osl::checkmate::FixedDepthSearcher::stand
const PieceStand stand(Player P) const
Definition fixedDepthSearcher.h:67
osl::checkmate::FixedDepthSearcher::attack
const ProofDisproof attack(int depth, Move &best_move, PieceStand &proof_pieces)
osl::checkmate::FixedDepthSearcher::defense
const ProofDisproof defense(Move last_move, int depth, PieceStand &proof_pieces)
osl::checkmate::FixedDepthSearcher::FixedDepthSearcher
FixedDepthSearcher()
Definition fixedDepthSearcher.h:46
osl::checkmate::FixedDepthSolverExt::hasEscapeByMove
const ProofDisproof hasEscapeByMove(Move next_move, int depth, Move &check_move, PieceStand &proof_pieces)
next_move を指して逃げられるかどうかを調べる
osl::checkmate::FixedDepthSolverExt::hasCheckmateMove
const ProofDisproof hasCheckmateMove(int depth, Move &best_move, PieceStand &proof_pieces)
stateがPから詰む局面かを返す.
osl::checkmate::FixedDepthSolverExt::hasCheckmateWithGuide
const ProofDisproof hasCheckmateWithGuide(int depth, Move &guide, PieceStand &proof_pieces)
guide を最初に試す． guide.isNormal() である必要はあるが，その局面でvalid でなくても良い
osl::checkmate::FixedDepthSolverExt::hasEscapeByMoveOfTurn
const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth, Move &check_move, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:83
osl::checkmate::FixedDepthSolverExt::hasCheckmateMoveOfTurn
const ProofDisproof hasCheckmateMoveOfTurn(int depth, Move &best_move, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:63
osl::checkmate::FixedDepthSolverExt::hasEscapeMove
const ProofDisproof hasEscapeMove(Move last_move, int depth, PieceStand &proof_pieces)
stateがPによって詰んでいる局面かを返す.
osl::checkmate::FixedDepthSolverExt::FixedDepthSolverExt
FixedDepthSolverExt()
Definition fixedDepthSolverExt.cc:37
osl::checkmate::FixedDepthSolverExt::hasCheckmateWithGuideOfTurn
const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move &guide, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:73
osl::checkmate::King8Info
敵玉の8近傍の状態を表す.
Definition king8Info.h:29
osl::checkmate::ProofDisproof
証明数(proof number)と反証数(disproof number).
Definition proofDisproof.h:17
fixedDepthSearcher.tcc
fixedDepthSolverExt.h
osl::checkmate::Edge_Table
EdgeTable Edge_Table
Definition proofNumberTable.cc:11
osl::checkmate::Proof_Number_Table
ProofNumberTable Proof_Number_Table
Definition proofNumberTable.cc:10
osl
Definition additionalEffect.h:6
osl::KING
@ KING
Definition basic_type.h:93
osl::Player
Player
Definition basic_type.h:8
osl::BLACK
@ BLACK
Definition basic_type.h:9
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
proofNumberTable.h
proofPieces.h
osl::checkmate::FixedDepthSolverExt::SetProofPieces
Definition fixedDepthSolverExt.cc:7
osl::checkmate::FixedDepthSolverExt::SetProofPieces::updateMax
static void updateMax(PieceStand child, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:22
osl::checkmate::FixedDepthSolverExt::SetProofPieces::clear
static void clear(PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:19
osl::checkmate::FixedDepthSolverExt::SetProofPieces::setAttackLeaf
static void setAttackLeaf(Move best_move, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:8
osl::checkmate::FixedDepthSolverExt::SetProofPieces::attackEstimation
static ProofDisproof attackEstimation(const NumEffectState &state, Player P, King8Info info)
Definition fixedDepthSolverExt.cc:29
osl::checkmate::FixedDepthSolverExt::SetProofPieces::setLeaf
static void setLeaf(const NumEffectState &state, Player P, PieceStand stand, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:16
osl::checkmate::FixedDepthSolverExt::SetProofPieces::attack
static void attack(Move best_move, PieceStand stand, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:13
osl::checkmate::FixedDepthSolverExt::SetProofPieces::addMonopolizedPieces
static void addMonopolizedPieces(const NumEffectState &state, Player P, PieceStand stand, PieceStand &proof_pieces)
Definition fixedDepthSolverExt.cc:25
osl::checkmate::ProofPiecesUtil::addMonopolizedPieces
static void addMonopolizedPieces(const SimpleState &state, Player player, const PieceStand max, PieceStand &out)
alt(player) が持っていない種類の持駒を playerが持っていたら out に独占分を加算する．
Definition proofPiecesUtil.h:23
osl::checkmate::ProofPieces::leaf
static const PieceStand leaf(const NumEffectState &state, Player attacker, const PieceStand max)
Definition proofPieces.h:14
osl::checkmate::ProofPieces::attack
static const PieceStand attack(const PieceStand prev, Move move, const PieceStand max)
Definition proofPieces.h:24
osl::misc::Player2Type
Definition basic_type.h:75
osl::move_classifier::Check
Definition check_.h:16