取り合い探索 (静止探索). More...
#include <quiescenceSearch2.h>
Public Types | |
enum | EvalUpdateState { AfterUpdate, BeforeUpdate } |
typedef EvalT | eval_t |
typedef NumEffectState | effect_state_t |
typedef container::MoveVector | MoveVector |
Public Member Functions | |
QuiescenceSearch2 (SearchState2Core &s, SimpleHashTable &t) | |
template<Player P> | |
int | search (eval_t &ev, Move last_move, int depth=QSearchTraits::MaxDepth) |
int | search (Player P, eval_t &ev, Move last_move, int depth=QSearchTraits::MaxDepth) |
template<Player P> | |
int | searchIteratively (eval_t &ev, Move last_move, int depth=QSearchTraits::MaxDepth) |
int | searchIteratively (Player P, eval_t &ev, Move last_move, int depth=QSearchTraits::MaxDepth) |
template<Player P> | |
int | searchIteratively (int alpha, int beta, eval_t &ev, Move last_move, int depth) |
template<Player P> | |
int | search (int alpha, int beta, eval_t &ev, Move last_move, int depth=QSearchTraits::MaxDepth) |
int | search (Player P, int alpha, int beta, eval_t &ev, Move last_move, int depth) |
template<Player P> | |
int | searchProbCut (int alpha, int beta, eval_t &ev, Move last_move) |
int | searchProbCut (Player P, int alpha, int beta, eval_t &ev, Move last_move) |
template<Player P> | |
int | searchInternal (int alpha, int beta, eval_t &ev, Move last_move, int additional_depth=0, EvalUpdateState need_eval_update=AfterUpdate) |
template<Player P, bool has_record> | |
int | staticValue (eval_t const &ev, int alpha, int beta, QuiescenceRecord *record) |
template<Player P, bool has_record, bool has_dont_capture, MoveType move_type> | |
bool | examineMoves (QuiescenceRecord *record, int &curVal, const Move *first, const Move *last, int &alpha, int beta, eval_t const &ev, int additional_depth, Square dont_capture=Square::STAND()) |
template<Player P> | |
int | takeBackValue (int alpha, int beta, eval_t const &ev, Move last_move) |
単純な取り返しの探索. More... | |
template<Player P> | |
bool | examineTakeBack (const MoveVector &moves, int &cur_val, int &alpha, int beta, eval_t const &ev) |
template<Player P, bool calm_move_only, bool first_nolmal_move_only> | |
bool | examineTakeBack2 (const MoveVector &moves, QuiescenceThreat &threat2, QuiescenceThreat &threat1, int beta, int beta2, eval_t const &ev) |
末端の取り返し用. More... | |
template<Player P, Ptype PTYPE> | |
bool | generateAndExamineTakeBack2 (MoveVector &moves, QuiescenceThreat &threat2, QuiescenceThreat &threat1, int beta1, int beta2, eval_t const &ev) |
末端の取り返し用. More... | |
template<Player P> | |
int | takeBackOrChase (int alpha, int beta, eval_t const &ev, Move last_move) |
last_move が逃げる手で、逃げた先の取り返し、または追撃の価値を判定 More... | |
template<Player P> | |
int | staticValueWithThreat (eval_t const &ev, int alpha, QuiescenceThreat &threat1, QuiescenceThreat &threat2) |
template<Player P> | |
int | staticValueWithThreat (eval_t const &ev) |
int | staticValueWithThreat (eval_t const &ev) |
int | nodeCount () const |
const NumEffectState & | currentState () const |
Private Types | |
typedef FixedEval | base_t |
![]() | |
enum | { MaxDepth = 8, CheckmateSpecialDepth = 127, HistorySpecialDepth = 126 } |
enum | { FirstThreat = 6, SecondThreat = 2 } |
enum | MoveType { UNKNOWN, KING_ESCAPE, CAPTURE, PROMOTE, CHECK, ESCAPE, ATTACK, OTHER } |
Private Member Functions | |
int | depthFromRoot () const |
rootからの深さ More... | |
int | depth () const |
残り深さ More... | |
template<Player P, bool has_record> | |
int | searchMain (QuiescenceRecord *record, int alpha, int beta, eval_t &ev, Move last_move, int additional_depth, EvalUpdateState &need_eval_update) |
template<Player P, Ptype PTYPE, bool has_record> | |
bool | examineCapture (QuiescenceRecord *record, int &curVal, MoveVector &working, int &alpha, int beta, eval_t const &ev, Piece last_piece, int additional_depth) |
PTYPE を取る手を生成して examineMoves を呼ぶ More... | |
template<Player P> | |
int | passValue (int alpha, int beta, eval_t const &ev) |
int | currentValueWithLastThreat (eval_t const &ev, Piece last_move_piece) |
Private Attributes | |
SearchState2Core & | state |
SimpleHashTable & | table |
int | root_depth |
int | max_depth |
int | node_count |
探索ノード数 More... | |
Additional Inherited Members | |
![]() | |
FixedEval () | |
void | setDrawValue (int value) |
int | drawValue () const |
~FixedEval () | |
![]() | |
static int | winByFoul (Player P) |
相手の王手千日手,打歩詰. More... | |
static int | winByLoop (Player P) |
駒得するループ. More... | |
static int | winByCheckmate (Player P) |
詰による勝 More... | |
static int | minusInfty (Player P) |
探索windowの下限 (負けでも更新される値) More... | |
static int | winThreshold (Player P) |
この値を越えれば勝. More... | |
static int | windowMax (Player P) |
探索して意味がある範囲 (偶数) More... | |
static int | brinkmatePenalty (Player P, int limit) |
必死(に見える)局面の評価値 Pが負けそう More... | |
static int | threatmatePenalty (Player P) |
末端で詰めろがかかっている場合のペナルティ. More... | |
static int | isWinValue (Player P, int val) |
勝かどうか. More... | |
取り合い探索 (静止探索).
TODO:
Definition at line 41 of file quiescenceSearch2.h.
|
private |
Definition at line 43 of file quiescenceSearch2.h.
typedef NumEffectState osl::search::QuiescenceSearch2< EvalT >::effect_state_t |
Definition at line 64 of file quiescenceSearch2.h.
typedef EvalT osl::search::QuiescenceSearch2< EvalT >::eval_t |
Definition at line 63 of file quiescenceSearch2.h.
typedef container::MoveVector osl::search::QuiescenceSearch2< EvalT >::MoveVector |
Definition at line 67 of file quiescenceSearch2.h.
enum osl::search::QuiescenceSearch2::EvalUpdateState |
Enumerator | |
---|---|
AfterUpdate | |
BeforeUpdate |
Definition at line 148 of file quiescenceSearch2.h.
|
inline |
Definition at line 69 of file quiescenceSearch2.h.
|
inline |
Definition at line 243 of file quiescenceSearch2.h.
References osl::search::QuiescenceSearch2< EvalT >::state, and osl::search::SearchState2Core::state().
|
private |
Definition at line 667 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::Piece::isPiece(), osl::KING, osl::Piece::owner(), osl::Piece::ptypeO(), and osl::Piece::square().
|
inlineprivate |
残り深さ
Definition at line 58 of file quiescenceSearch2.h.
References osl::search::QuiescenceSearch2< EvalT >::depthFromRoot(), and osl::search::QuiescenceSearch2< EvalT >::max_depth.
Referenced by osl::search::QuiescenceSearch2< EvalT >::search(), and osl::search::QuiescenceSearch2< EvalT >::searchIteratively().
|
inlineprivate |
rootからの深さ
Definition at line 53 of file quiescenceSearch2.h.
References osl::PathEncoding::getDepth(), osl::search::SearchState2Core::path(), osl::search::QuiescenceSearch2< EvalT >::root_depth, and osl::search::QuiescenceSearch2< EvalT >::state.
Referenced by osl::search::QuiescenceSearch2< EvalT >::depth().
|
inlineprivate |
PTYPE を取る手を生成して examineMoves を呼ぶ
Definition at line 264 of file quiescenceSearch2.tcc.
References moves, and osl::Piece::square().
bool osl::search::QuiescenceSearch2< EvalT >::examineMoves | ( | QuiescenceRecord * | record, |
int & | curVal, | ||
const Move * | first, | ||
const Move * | last, | ||
int & | alpha, | ||
int | beta, | ||
eval_t const & | ev, | ||
int | additional_depth, | ||
Square | dont_capture = Square::STAND() |
||
) |
dont_capture | TakeBack で試した手を後から重複して試さないために使う. template parameter の has_dont_capture がtrue の時だけ見る |
Definition at line 309 of file quiescenceSearch2.tcc.
References osl::alt(), osl::search::QuiescenceRecord::bestMove(), osl::eval::betterThan(), osl::eval::delta(), depth, osl::PtypeTable::hasUnblockableEffect(), osl::Sennichite::hasWinner(), osl::Move::isCapture(), osl::Sennichite::isDraw(), osl::isMajor(), osl::Sennichite::isNormal(), osl::Move::isNormal(), osl::Move::isPass(), osl::search::QuiescenceRecord::lowerBound(), osl::search::QuiescenceRecord::lowerDepth(), osl::eval::notLessThan(), osl::Move::ptype(), osl::Ptype_Table, osl::Move::ptypeO(), result, osl::search::QuiescenceRecord::setLowerBound(), osl::Move::to(), and osl::Sennichite::winner().
bool osl::search::QuiescenceSearch2< EvalT >::examineTakeBack | ( | const MoveVector & | moves, |
int & | cur_val, | ||
int & | alpha, | ||
int | beta, | ||
eval_t const & | ev | ||
) |
Definition at line 1433 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::eval::delta(), depth, osl::importantMove(), osl::eval::max(), osl::eval::notLessThan(), and result.
bool osl::search::QuiescenceSearch2< EvalT >::examineTakeBack2 | ( | const MoveVector & | moves, |
QuiescenceThreat & | threat2, | ||
QuiescenceThreat & | threat1, | ||
int | beta, | ||
int | beta2, | ||
eval_t const & | ev | ||
) |
末端の取り返し用.
二つthreatを求める
threat1 | 最大の脅威 |
threat2 | 2番目の脅威 |
calm_move_only | 相手の利きがあるマスにはいかない |
king_attack_piece | P に王手をかけている駒(のうちの一つ) |
Definition at line 1478 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::BISHOP, osl::eval::delta(), depth, osl::record::usi::escape(), finish, osl::PtypeTable::getEffect(), osl::EffectContent::hasEffect(), osl::importantMove(), osl::isMajor(), moves, osl::eval::notLessThan(), osl::Move::ptype(), osl::Ptype_Table, result, osl::ROOK, target, osl::Move::to(), osl::unpromote(), and osl::search::QuiescenceThreat::value.
|
inline |
末端の取り返し用.
各取れる駒毎に指手を生成して examineTakeBack2 を呼ぶ
Definition at line 234 of file quiescenceSearch2.tcc.
References osl::alt(), osl::Piece::isOnBoardByOwner(), osl::KNIGHT, osl::LANCE, moves, osl::PAWN, result, osl::Piece::square(), and target.
|
inline |
Definition at line 242 of file quiescenceSearch2.h.
References osl::search::QuiescenceSearch2< EvalT >::node_count.
|
private |
Definition at line 710 of file quiescenceSearch2.tcc.
References BOOST_STATIC_ASSERT(), max_depth, and result.
|
inline |
Definition at line 75 of file quiescenceSearch2.h.
References osl::alt(), osl::search::QuiescenceSearch2< EvalT >::depth(), osl::search::QuiescenceSearch2< EvalT >::max_depth, osl::Move::player(), osl::search::QuiescenceSearch2< EvalT >::state, osl::search::SearchState2Core::state(), and osl::search::FixedEval::winThreshold().
|
inline |
Definition at line 85 of file quiescenceSearch2.h.
References osl::BLACK, and osl::search::QuiescenceSearch2< EvalT >::depth().
|
inline |
Definition at line 126 of file quiescenceSearch2.h.
References osl::search::QuiescenceSearch2< EvalT >::depth(), and osl::search::QuiescenceSearch2< EvalT >::max_depth.
|
inline |
Definition at line 132 of file quiescenceSearch2.h.
References osl::BLACK, and osl::search::QuiescenceSearch2< EvalT >::depth().
int osl::search::QuiescenceSearch2< EvalT >::searchInternal | ( | int | alpha, |
int | beta, | ||
eval_t & | ev, | ||
Move | last_move, | ||
int | additional_depth = 0 , |
||
EvalUpdateState | need_eval_update = AfterUpdate |
||
) |
Definition at line 587 of file quiescenceSearch2.tcc.
References allocate_depth_in_threatmate, osl::alt(), osl::eval::betterThan(), depth, osl::eval::notLessThan(), osl::Move::player(), osl::search::qallocate(), quiecence_assert, result, and osl::search::QuiescenceRecord::updateThreatmate().
|
inline |
Definition at line 94 of file quiescenceSearch2.h.
References osl::alt(), osl::search::QuiescenceSearch2< EvalT >::depth(), osl::Move::player(), osl::search::QuiescenceSearch2< EvalT >::state, osl::search::SearchState2Core::state(), and osl::search::FixedEval::winThreshold().
|
inline |
Definition at line 103 of file quiescenceSearch2.h.
References osl::BLACK, and osl::search::QuiescenceSearch2< EvalT >::depth().
|
inline |
Definition at line 113 of file quiescenceSearch2.h.
References osl::search::QuiescenceSearch2< EvalT >::depth(), osl::search::QuiescenceSearch2< EvalT >::max_depth, and result.
|
private |
Definition at line 731 of file quiescenceSearch2.tcc.
References osl::stat::Ratio::add(), osl::search::QuiescenceRecord::addKillerMoves(), allocate_depth_in_threatmate, osl::alt(), osl::search::QuiescenceRecord::bestMove(), osl::eval::betterThan(), osl::BISHOP, osl::canPromote(), osl::ntesuki::capture(), osl::Move::capturePtype(), osl::search::QuiescenceRecord::checkmateNodesLeft(), osl::eval::delta(), depth, osl::find(), finish, osl::Move::from(), osl::Move::isCapture(), osl::Move::isDrop(), osl::isMajor(), osl::isMajorBasic(), osl::Move::isNormal(), osl::Move::isPass(), osl::isPiece(), osl::Piece::isPiece(), osl::Square::isPieceStand(), osl::search::DualThreatmateState::isThreatmate(), osl::Move::isValid(), osl::KING, osl::KNIGHT, osl::LANCE, osl::search::QuiescenceRecord::loadMoves(), osl::search::QuiescenceRecord::lowerBound(), osl::search::QuiescenceRecord::lowerDepth(), osl::eval::max(), max_depth, osl::search::DualThreatmateState::maybeThreatmate(), osl::search::DualThreatmateState::mayHaveCheckmate(), osl::eval::min(), moves, osl::search::QuiescenceRecord::movesEmpty(), osl::search::QuiescenceRecord::movesSizeLessThan(), osl::newPtypeO(), osl::eval::notLessThan(), osl::Piece::owner(), osl::PAWN, osl::promote(), osl::Move::ptype(), osl::PTYPE_EMPTY, osl::search::qallocate(), ratio, result, osl::ROOK, osl::search::QuiescenceRecord::sendOffSquare(), osl::search::QuiescenceRecord::setLowerBound(), osl::search::QuiescenceRecord::setUpperBound(), osl::Piece::square(), osl::search::QuiescenceRecordBase::threatmate, osl::search::DualThreatmateState::threatmateMove(), osl::Move::to(), osl::unpromote(), osl::search::QuiescenceRecord::upperBound(), and osl::search::QuiescenceRecord::upperDepth().
int osl::search::QuiescenceSearch2< EvalT >::searchProbCut | ( | int | alpha, |
int | beta, | ||
eval_t & | ev, | ||
Move | last_move | ||
) |
Definition at line 208 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::eval::max(), max_depth, osl::eval::min(), osl::newPtypeO(), osl::eval::notLessThan(), and osl::PAWN.
|
inline |
Definition at line 140 of file quiescenceSearch2.h.
References osl::BLACK.
|
inline |
Definition at line 469 of file quiescenceSearch2.tcc.
References allocate_depth_in_threatmate, osl::eval::betterThan(), osl::Move::capturePtype(), depth, osl::GOLD, osl::search::QuiescenceRecord::hasStaticValue(), osl::Move::isNormal(), osl::Piece::isPiece(), osl::Move::isValid(), osl::search::DualThreatmateState::maybeThreatmate(), osl::newPtypeO(), osl::PROOK, osl::Move::ptype(), osl::Piece::ptypeO(), osl::search::qallocate(), result, osl::search::QuiescenceRecord::setStaticValue(), osl::search::DualThreatmateState::setThreatmate(), osl::SILVER, osl::search::QuiescenceRecordBase::threatmate, osl::search::QuiescenceRecord::threatmateNodesLeft(), osl::Move::to(), osl::Square::x(), and osl::Square::y().
int osl::search::QuiescenceSearch2< EvalT >::staticValueWithThreat | ( | eval_t const & | ev, |
int | alpha, | ||
QuiescenceThreat & | threat1, | ||
QuiescenceThreat & | threat2 | ||
) |
Definition at line 1753 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::eval::delta(), depth, finish, osl::isMajorBasic(), osl::Move::isNormal(), osl::eval::max(), max_depth, osl::eval::min(), osl::search::QuiescenceThreat::move, moves, osl::eval::notLessThan(), osl::Piece::owner(), osl::Piece::ptype(), result, osl::Piece::square(), target, osl::Move::to(), and osl::search::QuiescenceThreat::value.
|
inline |
Definition at line 229 of file quiescenceSearch2.h.
References osl::alt(), and osl::search::FixedEval::winThreshold().
|
inline |
Definition at line 235 of file quiescenceSearch2.h.
References osl::BLACK, osl::search::QuiescenceSearch2< EvalT >::state, and osl::search::SearchState2Core::state().
int osl::search::QuiescenceSearch2< EvalT >::takeBackOrChase | ( | int | alpha, |
int | beta, | ||
eval_t const & | ev, | ||
Move | last_move | ||
) |
last_move が逃げる手で、逃げた先の取り返し、または追撃の価値を判定
Definition at line 1657 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::Move::from(), osl::Move::isNormal(), osl::eval::max(), moves, osl::newPtypeO(), osl::PROOK, osl::Move::ptypeO(), result, osl::ROOK, and osl::Move::to().
int osl::search::QuiescenceSearch2< EvalT >::takeBackValue | ( | int | alpha, |
int | beta, | ||
eval_t const & | ev, | ||
Move | last_move | ||
) |
単純な取り返しの探索.
PieceEval::computeDiffAfterMoveForRP と異なり,盤面を動かす. 王手を正確に判定し,利きも伸びる
attack_piece | last_move が王手回避の時に王手をかけていた駒 |
Definition at line 1695 of file quiescenceSearch2.tcc.
References osl::alt(), osl::eval::betterThan(), osl::eval::delta(), osl::Move::isPass(), osl::LANCE, moves, osl::eval::notLessThan(), osl::Piece::square(), and osl::Move::to().
|
private |
Definition at line 47 of file quiescenceSearch2.h.
Referenced by osl::search::QuiescenceSearch2< EvalT >::depth(), osl::search::QuiescenceSearch2< EvalT >::search(), and osl::search::QuiescenceSearch2< EvalT >::searchIteratively().
|
private |
探索ノード数
Definition at line 51 of file quiescenceSearch2.h.
Referenced by osl::search::QuiescenceSearch2< EvalT >::nodeCount().
|
private |
Definition at line 46 of file quiescenceSearch2.h.
Referenced by osl::search::QuiescenceSearch2< EvalT >::depthFromRoot().
|
private |
Definition at line 44 of file quiescenceSearch2.h.
Referenced by osl::search::QuiescenceSearch2< EvalT >::currentState(), osl::search::QuiescenceSearch2< EvalT >::depthFromRoot(), osl::search::QuiescenceSearch2< EvalT >::search(), osl::search::QuiescenceSearch2< EvalT >::searchIteratively(), and osl::search::QuiescenceSearch2< EvalT >::staticValueWithThreat().
|
private |
Definition at line 45 of file quiescenceSearch2.h.