fixedDepthSearcher.h
Go to the documentation of this file.
1 /* fixedDepthSearcher.h
2  */
3 #ifndef OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H
4 #define OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H
6 #include "osl/numEffectState.h"
7 #include "osl/bits/king8Info.h"
8 #include "osl/bits/pieceStand.h"
9 
10 namespace osl
11 {
12  namespace checkmate
13  {
15  {
16  static void setAttackLeaf(Move /*best_move*/, PieceStand& /*proof_pieces*/) {
17  }
18  static void attack(Move /*best_move*/, PieceStand, PieceStand& /*proof_pieces*/) {
19  }
21  }
22  static void clear(PieceStand& /*proof_pieces*/) {
23  }
24  static void updateMax(PieceStand /*child*/, PieceStand& /*proof_pieces*/) {
25  }
27  PieceStand&) {
28  }
30  return ProofDisproof();
31  }
32  };
41  {
42  protected:
44  int count;
45  public:
46  FixedDepthSearcher() : state(0), count(0)
47  {
48  }
50  : state(&s), count(0)
51  {
52  }
54  {
55  state = &s;
56  }
57  private:
58  void addCount()
59  {
60  count++;
61  }
62  public:
63  int getCount() const
64  {
65  return count;
66  }
67  const PieceStand stand(Player P) const
68  {
69  return PieceStand(P, *state);
70  }
71  public:
72  // private: Note: helper の都合
73  template <Player P, class SetPieces, bool HasGuide>
74  const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
75  template <Player P, class SetPieces, bool HasGuide>
76  const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
77  template <Player P, class SetPieces>
78  const ProofDisproof defense(Move last_move,int depth,
79  PieceStand& proof_pieces);
80  private:
84  template <Player P, class SetPieces>
85  const ProofDisproof defenseEstimation(Move last_move, PieceStand& proof_pieces,
86  Piece attacker_piece,
87  Square target_position) const;
88  public:
89  template <Player P>
90  const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
91  {
92  PieceStand proof_pieces;
93  return attack<P,NoProofPieces,false>(depth, best_move, proof_pieces);
94  }
95  template <Player P>
97  {
98  Move checkmate_move;
99  return hasCheckmateMove<P>(depth, checkmate_move);
100  }
101 
102  template <Player P>
103  const ProofDisproof hasEscapeMove(Move last_move,int depth)
104  {
105  PieceStand proof_pieces;
106  return defense<P,NoProofPieces>(last_move, depth, proof_pieces);
107  }
108  template <Player P>
109  const ProofDisproof hasEscapeByMove(Move next_move, int depth);
110 
111  const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
112  const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
113  const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
114 
118  template <Player Defense>
119  void generateBlockingWhenLiberty0(Piece defense_king, Square attack_from,
120  CheckMoveVector& moves) const;
121  template <Player Defense>
122  int blockEstimation(Square attack_from, Square defense_king) const;
123  };
124  } // namespace checkmate
125 } // namespace osl
126 
127 #endif /* OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H */
128 // ;;; Local Variables:
129 // ;;; mode:c++
130 // ;;; c-basic-offset:2
131 // ;;; End:
深さ固定で,その深さまで depth first searchで読む詰将棋.
const PieceStand stand(Player P) const
const ProofDisproof hasEscapeMove(Move last_move, int depth)
const ProofDisproof hasCheckmateMove(int depth, Move &best_move)
圧縮していない moveの表現 .
Definition: basic_type.h:1051
static void setAttackLeaf(Move, PieceStand &)
敵玉の8近傍の状態を表す.
Definition: king8Info.h:28
static void setLeaf(const NumEffectState &, Player, PieceStand, PieceStand &)
static void updateMax(PieceStand, PieceStand &)
static ProofDisproof attackEstimation(const NumEffectState &, Player, King8Info)
利きを持つ局面
証明数(proof number)と反証数(disproof number).
Definition: proofDisproof.h:16
Player
Definition: basic_type.h:8
static void clear(PieceStand &)
片方の手番の持駒の枚数を記録するクラス.
const ProofDisproof hasCheckmateMove(int depth)
static void attack(Move, PieceStand, PieceStand &)
static void addMonopolizedPieces(const NumEffectState &, Player, PieceStand, PieceStand &)