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:
圧縮していない moveの表現 .
Definition: basic_type.h:1052
Ptype ptype() const
Definition: basic_type.h:1155
bool isDrop() const
Definition: basic_type.h:1150
const Move newCapture(Piece capture) const
Definition: basic_type.h:1231
bool isNormal() const
INVALID でも PASS でもない.
Definition: basic_type.h:1088
const Square to() const
Definition: basic_type.h:1132
const Square from() const
Definition: basic_type.h:1125
利きを持つ局面
片方の手番の持駒の枚数を記録するクラス.
void add(Ptype type, unsigned int num=1)
const PieceStand max(PieceStand other) const
種類毎に this と other の持駒の多い方を取る
bool isPtype() const
Definition: basic_type.h:930
Square kingSquare() const
Definition: simpleState.h:94
const King8Info resetEdgeFromLiberty(Player king_player, Square king, King8Info info) const
liberty から盤の淵(xかyが1か9)を取り除く.
深さ固定で,その深さまで depth first searchで読む詰将棋.
const PieceStand stand(Player P) const
const ProofDisproof hasEscapeByMove(Move next_move, int depth, Move &check_move, PieceStand &proof_pieces)
next_move を指して逃げられるかどうかを調べる
const ProofDisproof hasCheckmateMove(int depth, Move &best_move, PieceStand &proof_pieces)
stateがPから詰む局面かを返す.
const ProofDisproof hasCheckmateWithGuide(int depth, Move &guide, PieceStand &proof_pieces)
guide を最初に試す. guide.isNormal() である必要はあるが,その局面でvalid でなくても良い
const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth, Move &check_move, PieceStand &proof_pieces)
const ProofDisproof hasCheckmateMoveOfTurn(int depth, Move &best_move, PieceStand &proof_pieces)
const ProofDisproof hasEscapeMove(Move last_move, int depth, PieceStand &proof_pieces)
stateがPによって詰んでいる局面かを返す.
const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move &guide, PieceStand &proof_pieces)
敵玉の8近傍の状態を表す.
Definition: king8Info.h:29
証明数(proof number)と反証数(disproof number).
Definition: proofDisproof.h:17
const ProofDisproof attackEstimation(const NumEffectState &state) const
全て
EdgeTable Edge_Table
ProofNumberTable Proof_Number_Table
@ KING
Definition: basic_type.h:93
Player
Definition: basic_type.h:8
@ BLACK
Definition: basic_type.h:9
constexpr Player alt(Player player)
Definition: basic_type.h:13
static void updateMax(PieceStand child, PieceStand &proof_pieces)
static void setAttackLeaf(Move best_move, PieceStand &proof_pieces)
static ProofDisproof attackEstimation(const NumEffectState &state, Player P, King8Info info)
static void setLeaf(const NumEffectState &state, Player P, PieceStand stand, PieceStand &proof_pieces)
static void attack(Move best_move, PieceStand stand, PieceStand &proof_pieces)
static void addMonopolizedPieces(const NumEffectState &state, Player P, PieceStand stand, PieceStand &proof_pieces)
static void addMonopolizedPieces(const SimpleState &state, Player player, const PieceStand max, PieceStand &out)
alt(player) が持っていない種類の持駒を playerが持っていたら out に独占分を加算する.
static const PieceStand leaf(const NumEffectState &state, Player attacker, const PieceStand max)
Definition: proofPieces.h:14
static const PieceStand attack(const PieceStand prev, Move move, const PieceStand max)
Definition: proofPieces.h:24