My Project
fixedDepthSolverExt.cc
Go to the documentation of this file.
5 
7 {
8  static void setAttackLeaf(Move best_move, PieceStand& proof_pieces) {
9  proof_pieces = PieceStand();
10  if (best_move.isDrop())
11  proof_pieces.add(best_move.ptype());
12  }
13  static void attack(Move best_move, PieceStand stand, PieceStand& proof_pieces) {
14  proof_pieces = ProofPieces::attack(proof_pieces, best_move, stand);
15  }
16  static void setLeaf(const NumEffectState& state, Player P, PieceStand stand, PieceStand& proof_pieces) {
17  proof_pieces = ProofPieces::leaf(state, P, stand);
18  }
19  static void clear(PieceStand& proof_pieces) {
20  proof_pieces = PieceStand();
21  }
22  static void updateMax(PieceStand child, PieceStand& proof_pieces) {
23  proof_pieces = proof_pieces.max(child);
24  }
26  PieceStand stand, PieceStand& proof_pieces) {
28  }
30  auto target_king = state.kingSquare(alt(P));
31  const King8Info info_modified
32  = Edge_Table.resetEdgeFromLiberty(alt(P), target_king, info);
33  return Proof_Number_Table.attackEstimation(state, P, info_modified, target_king);
34  }
35 };
36 
38 {
39 }
40 
43 {
44 }
45 
46 template <osl::Player P>
49 hasEscapeByMove(Move next_move, int depth, Move& check_move,
50  PieceStand& proof_pieces)
51 {
52  typedef FixedDefenseHelper<P,SetProofPieces,true> helper_t;
53  proof_pieces = PieceStand();
54  ProofDisproof pdp;
55  helper_t helper(*this, depth+1, pdp, proof_pieces);
56  state->makeUnmakeMove(Player2Type<alt(P)>(),next_move,helper);
57  check_move = helper.best_move;
58  return pdp;
59 }
60 
63 hasCheckmateMoveOfTurn(int depth, Move& best_move, PieceStand& proof_pieces)
64 {
65  if (state->turn() == BLACK)
66  return hasCheckmateMove<BLACK>(depth, best_move, proof_pieces);
67  else
68  return hasCheckmateMove<WHITE>(depth, best_move, proof_pieces);
69 }
70 
73 hasCheckmateWithGuideOfTurn(int depth, Move& guide, PieceStand& proof_pieces)
74 {
75  if (state->turn() == BLACK)
76  return hasCheckmateWithGuide<BLACK>(depth, guide, proof_pieces);
77  else
78  return hasCheckmateWithGuide<WHITE>(depth, guide, proof_pieces);
79 }
80 
83 hasEscapeByMoveOfTurn(Move next_move, int depth,
84  Move& check_move, PieceStand& proof_pieces)
85 {
86  if (state->turn() == BLACK)
87  return hasEscapeByMove<WHITE>(next_move, depth, check_move, proof_pieces);
88  else
89  return hasEscapeByMove<BLACK>(next_move, depth, check_move, proof_pieces);
90 }
91 
92 template <osl::Player P>
95 hasCheckmateWithGuide(int depth, Move& guide, PieceStand& proof_pieces)
96 {
97  assert(guide.isNormal());
98  if (! guide.isDrop())
99  {
100  const Piece p=state->pieceOnBoard(guide.to());
101  if (!p.isPtype<KING>())
102  guide=guide.newCapture(p);
103  }
104  if (state->template isAlmostValidMove<false>(guide)
106  ::isMember(*state, guide.ptype(), guide.from(), guide.to()))
107  return attack<P,SetProofPieces,true>(depth, guide, proof_pieces);
108  return attack<P,SetProofPieces,false>(depth, guide, proof_pieces);
109 }
110 
111 template <osl::Player P>
113 FixedDepthSolverExt::hasCheckmateMove(int depth, Move& best_move,
114  PieceStand& proof_pieces) {
115  return attack<P,SetProofPieces,false>(depth, best_move, proof_pieces);
116 }
117 
118 template <osl::Player P>
120 FixedDepthSolverExt::hasEscapeMove(Move last_move,int depth,
121  PieceStand& proof_pieces) {
122  return defense<P,SetProofPieces>(last_move, depth, proof_pieces);
123 }
124 
125 namespace osl
126 {
127  template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasCheckmateMove<BLACK>(int, Move&, PieceStand&);
128  template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasCheckmateMove<WHITE>(int, Move&, PieceStand&);
129  template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeMove<BLACK>(Move, int, PieceStand&);
130  template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeMove<WHITE>(Move, int, PieceStand&);
131  template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeByMove<BLACK>(Move, int, Move&, PieceStand&);
132  template const checkmate::ProofDisproof checkmate::FixedDepthSolverExt::hasEscapeByMove<WHITE>(Move, int, Move&, PieceStand&);
133 }
134 
135 // ;;; Local Variables:
136 // ;;; mode:c++
137 // ;;; c-basic-offset:2
138 // ;;; End:
osl::checkmate::FixedDepthSolverExt::hasEscapeMove
const ProofDisproof hasEscapeMove(Move last_move, int depth, PieceStand &proof_pieces)
stateがPによって詰んでいる局面かを返す.
osl::checkmate::FixedDepthSolverExt::hasCheckmateMoveOfTurn
const ProofDisproof hasCheckmateMoveOfTurn(int depth, Move &best_move, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:63
osl::move_classifier::Check
Definition: check_.h:16
osl::checkmate::ProofPieces::leaf
static const PieceStand leaf(const NumEffectState &state, Player attacker, const PieceStand max)
Definition: proofPieces.h:14
proofNumberTable.h
proofPieces.h
osl::alt
constexpr Player alt(Player player)
Definition: basic_type.h:13
osl::checkmate::FixedDepthSolverExt::hasCheckmateWithGuide
const ProofDisproof hasCheckmateWithGuide(int depth, Move &guide, PieceStand &proof_pieces)
guide を最初に試す. guide.isNormal() である必要はあるが,その局面でvalid でなくても良い
osl::checkmate::ProofNumberTable::attackEstimation
const ProofDisproof attackEstimation(const NumEffectState &state) const
全て
Definition: proofNumberTable.cc:357
osl::checkmate::FixedDepthSolverExt::hasEscapeByMove
const ProofDisproof hasEscapeByMove(Move next_move, int depth, Move &check_move, PieceStand &proof_pieces)
next_move を指して逃げられるかどうかを調べる
osl::Move
圧縮していない moveの表現 .
Definition: basic_type.h:1052
osl::checkmate::ProofPieces::attack
static const PieceStand attack(const PieceStand prev, Move move, const PieceStand max)
Definition: proofPieces.h:24
osl::checkmate::FixedDepthSolverExt::SetProofPieces::clear
static void clear(PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:19
osl::checkmate::FixedDepthSolverExt::hasCheckmateMove
const ProofDisproof hasCheckmateMove(int depth, Move &best_move, PieceStand &proof_pieces)
stateがPから詰む局面かを返す.
osl::misc::Player2Type
Definition: basic_type.h:75
osl::Piece::isPtype
bool isPtype() const
Definition: basic_type.h:930
osl::checkmate::FixedDepthSearcher::stand
const PieceStand stand(Player P) const
Definition: fixedDepthSearcher.h:67
osl::Piece
駒.
Definition: basic_type.h:788
osl::checkmate::FixedDepthSearcher::state
NumEffectState * state
Definition: fixedDepthSearcher.h:43
fixedDepthSearcher.tcc
osl::KING
@ KING
Definition: basic_type.h:93
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::SetProofPieces::attack
static void attack(Move best_move, PieceStand stand, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:13
osl::Move::isDrop
bool isDrop() const
Definition: basic_type.h:1150
osl::PieceStand
片方の手番の持駒の枚数を記録するクラス.
Definition: bits/pieceStand.h:38
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition: basic_type.h:1088
osl::checkmate::FixedDepthSolverExt::SetProofPieces::attackEstimation
static ProofDisproof attackEstimation(const NumEffectState &state, Player P, King8Info info)
Definition: fixedDepthSolverExt.cc:29
osl::checkmate::FixedDepthSolverExt::SetProofPieces::addMonopolizedPieces
static void addMonopolizedPieces(const NumEffectState &state, Player P, PieceStand stand, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:25
osl::PieceStand::add
void add(Ptype type, unsigned int num=1)
Definition: bits/pieceStand.h:68
osl::Move::from
const Square from() const
Definition: basic_type.h:1125
osl::checkmate::FixedDepthSolverExt::SetProofPieces::setAttackLeaf
static void setAttackLeaf(Move best_move, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:8
osl::checkmate::FixedDepthSolverExt::SetProofPieces::updateMax
static void updateMax(PieceStand child, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:22
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
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::FixedDepthSolverExt::hasCheckmateWithGuideOfTurn
const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move &guide, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:73
fixedDepthSolverExt.h
osl::SimpleState::kingSquare
Square kingSquare() const
Definition: simpleState.h:94
osl::checkmate::Proof_Number_Table
ProofNumberTable Proof_Number_Table
Definition: proofNumberTable.cc:10
osl::checkmate::EdgeTable::resetEdgeFromLiberty
const King8Info resetEdgeFromLiberty(Player king_player, Square king, King8Info info) const
liberty から盤の淵(xかyが1か9)を取り除く.
Definition: proofNumberTable.h:211
osl::checkmate::Edge_Table
EdgeTable Edge_Table
Definition: proofNumberTable.cc:11
osl::Move::ptype
Ptype ptype() const
Definition: basic_type.h:1155
osl::BLACK
@ BLACK
Definition: basic_type.h:9
osl::checkmate::FixedDepthSolverExt::FixedDepthSolverExt
FixedDepthSolverExt()
Definition: fixedDepthSolverExt.cc:37
osl::checkmate::ProofDisproof
証明数(proof number)と反証数(disproof number).
Definition: proofDisproof.h:17
osl::checkmate::FixedDepthSearcher
深さ固定で,その深さまで depth first searchで読む詰将棋.
Definition: fixedDepthSearcher.h:41
osl::checkmate::FixedDepthSolverExt::SetProofPieces::setLeaf
static void setLeaf(const NumEffectState &state, Player P, PieceStand stand, PieceStand &proof_pieces)
Definition: fixedDepthSolverExt.cc:16
osl::Move::newCapture
const Move newCapture(Piece capture) const
Definition: basic_type.h:1231
osl::Player
Player
Definition: basic_type.h:8
osl::Move::to
const Square to() const
Definition: basic_type.h:1132
osl::checkmate::FixedDepthSolverExt::SetProofPieces
Definition: fixedDepthSolverExt.cc:7
osl::checkmate::King8Info
敵玉の8近傍の状態を表す.
Definition: king8Info.h:29
osl
Definition: additionalEffect.h:6
osl::PieceStand::max
const PieceStand max(PieceStand other) const
種類毎に this と other の持駒の多い方を取る
Definition: bits/pieceStand.h:171