fixedDepthSearcher.h
Go to the documentation of this file.
/* fixedDepthSearcher.h
*/
#ifndef OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H
#define OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H
#include "osl/checkmate/proofDisproof.h"
#include "osl/numEffectState.h"
#include "osl/bits/king8Info.h"
#include "osl/bits/pieceStand.h"
namespace osl
{
namespace checkmate
{
struct NoProofPieces
{
static void setAttackLeaf(Move /*best_move*/, PieceStand& /*proof_pieces*/) {
}
static void attack(Move /*best_move*/, PieceStand, PieceStand& /*proof_pieces*/) {
}
static void setLeaf(const NumEffectState&, Player, PieceStand, PieceStand&) {
}
static void clear(PieceStand& /*proof_pieces*/) {
}
static void updateMax(PieceStand /*child*/, PieceStand& /*proof_pieces*/) {
}
static void addMonopolizedPieces(const NumEffectState&, Player, PieceStand,
PieceStand&) {
}
static ProofDisproof attackEstimation(const NumEffectState&, Player, King8Info) {
return ProofDisproof();
}
};
class FixedDepthSearcher
{
protected:
NumEffectState *state;
int count;
public:
FixedDepthSearcher() : state(0), count(0)
{
}
explicit FixedDepthSearcher(NumEffectState& s)
: state(&s), count(0)
{
}
void setState(NumEffectState& s)
{
state = &s;
}
private:
void addCount()
{
count++;
}
public:
int getCount() const
{
return count;
}
const PieceStand stand(Player P) const
{
return PieceStand(P, *state);
}
public:
// private: Note: helper の都合
template <Player P, class SetPieces, bool HasGuide>
const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
template <Player P, class SetPieces, bool HasGuide>
const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
template <Player P, class SetPieces>
const ProofDisproof defense(Move last_move,int depth,
PieceStand& proof_pieces);
private:
template <Player P, class SetPieces>
const ProofDisproof defenseEstimation(Move last_move, PieceStand& proof_pieces,
Piece attacker_piece,
Square target_position) const;
public:
template <Player P>
const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
{
PieceStand proof_pieces;
return attack<P,NoProofPieces,false>(depth, best_move, proof_pieces);
}
template <Player P>
const ProofDisproof hasCheckmateMove(int depth)
{
Move checkmate_move;
return hasCheckmateMove<P>(depth, checkmate_move);
}
template <Player P>
const ProofDisproof hasEscapeMove(Move last_move,int depth)
{
PieceStand proof_pieces;
return defense<P,NoProofPieces>(last_move, depth, proof_pieces);
}
template <Player P>
const ProofDisproof hasEscapeByMove(Move next_move, int depth);
const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
template <Player Defense>
void generateBlockingWhenLiberty0(Piece defense_king, Square attack_from,
CheckMoveVector& moves) const;
template <Player Defense>
int blockEstimation(Square attack_from, Square defense_king) const;
};
} // namespace checkmate
} // namespace osl
#endif /* OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
pieceStand.h
osl::CheckMoveVector
Definition container.h:301
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::PieceStand
片方の手番の持駒の枚数を記録するクラス.
Definition bits/pieceStand.h:38
osl::Piece
駒.
Definition basic_type.h:788
osl::Square
Definition basic_type.h:532
osl::checkmate::FixedDepthSearcher::defenseEstimation
const ProofDisproof defenseEstimation(Move last_move, PieceStand &proof_pieces, Piece attacker_piece, Square target_position) const
move を作らずに ProofDisproof の予測を計算する
osl::checkmate::FixedDepthSearcher::generateBlockingWhenLiberty0
void generateBlockingWhenLiberty0(Piece defense_king, Square attack_from, CheckMoveVector &moves) const
無駄合をなるべく生成しない，合駒生成
osl::checkmate::FixedDepthSearcher::hasEscapeByMove
const ProofDisproof hasEscapeByMove(Move next_move, int depth)
osl::checkmate::FixedDepthSearcher::addCount
void addCount()
Definition fixedDepthSearcher.h:58
osl::checkmate::FixedDepthSearcher::state
NumEffectState * state
Definition fixedDepthSearcher.h:43
osl::checkmate::FixedDepthSearcher::hasCheckmateMoveOfTurn
const ProofDisproof hasCheckmateMoveOfTurn(int depth, Move &best_move)
Definition fixedDepthSearcher.cc:10
osl::checkmate::FixedDepthSearcher::count
int count
Definition fixedDepthSearcher.h:44
osl::checkmate::FixedDepthSearcher::stand
const PieceStand stand(Player P) const
Definition fixedDepthSearcher.h:67
osl::checkmate::FixedDepthSearcher::hasCheckmateMove
const ProofDisproof hasCheckmateMove(int depth)
Definition fixedDepthSearcher.h:96
osl::checkmate::FixedDepthSearcher::getCount
int getCount() const
Definition fixedDepthSearcher.h:63
osl::checkmate::FixedDepthSearcher::attack
const ProofDisproof attack(int depth, Move &best_move, PieceStand &proof_pieces)
osl::checkmate::FixedDepthSearcher::setState
void setState(NumEffectState &s)
Definition fixedDepthSearcher.h:53
osl::checkmate::FixedDepthSearcher::defense
const ProofDisproof defense(Move last_move, int depth, PieceStand &proof_pieces)
osl::checkmate::FixedDepthSearcher::hasEscapeByMoveOfTurn
const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth)
Definition fixedDepthSearcher.cc:30
osl::checkmate::FixedDepthSearcher::hasEscapeMove
const ProofDisproof hasEscapeMove(Move last_move, int depth)
Definition fixedDepthSearcher.h:103
osl::checkmate::FixedDepthSearcher::hasEscapeMoveOfTurn
const ProofDisproof hasEscapeMoveOfTurn(Move last_move, int depth)
Definition fixedDepthSearcher.cc:20
osl::checkmate::FixedDepthSearcher::blockEstimation
int blockEstimation(Square attack_from, Square defense_king) const
osl::checkmate::FixedDepthSearcher::hasCheckmateMove
const ProofDisproof hasCheckmateMove(int depth, Move &best_move)
Definition fixedDepthSearcher.h:90
osl::checkmate::FixedDepthSearcher::FixedDepthSearcher
FixedDepthSearcher()
Definition fixedDepthSearcher.h:46
osl::checkmate::FixedDepthSearcher::attackMayUnsafe
const ProofDisproof attackMayUnsafe(int depth, Move &best_move, PieceStand &proof_pieces)
osl::checkmate::FixedDepthSearcher::FixedDepthSearcher
FixedDepthSearcher(NumEffectState &s)
Definition fixedDepthSearcher.h:49
osl::checkmate::King8Info
敵玉の8近傍の状態を表す.
Definition king8Info.h:29
osl::checkmate::ProofDisproof
証明数(proof number)と反証数(disproof number).
Definition proofDisproof.h:17
king8Info.h
osl::checkmate
Definition king8Info.h:12
osl
Definition additionalEffect.h:6
osl::Player
Player
Definition basic_type.h:8
numEffectState.h
proofDisproof.h
osl::checkmate::NoProofPieces
Definition fixedDepthSearcher.h:15
osl::checkmate::NoProofPieces::setAttackLeaf
static void setAttackLeaf(Move, PieceStand &)
Definition fixedDepthSearcher.h:16
osl::checkmate::NoProofPieces::setLeaf
static void setLeaf(const NumEffectState &, Player, PieceStand, PieceStand &)
Definition fixedDepthSearcher.h:20
osl::checkmate::NoProofPieces::clear
static void clear(PieceStand &)
Definition fixedDepthSearcher.h:22
osl::checkmate::NoProofPieces::attackEstimation
static ProofDisproof attackEstimation(const NumEffectState &, Player, King8Info)
Definition fixedDepthSearcher.h:29
osl::checkmate::NoProofPieces::attack
static void attack(Move, PieceStand, PieceStand &)
Definition fixedDepthSearcher.h:18
osl::checkmate::NoProofPieces::addMonopolizedPieces
static void addMonopolizedPieces(const NumEffectState &, Player, PieceStand, PieceStand &)
Definition fixedDepthSearcher.h:26
osl::checkmate::NoProofPieces::updateMax
static void updateMax(PieceStand, PieceStand &)
Definition fixedDepthSearcher.h:24