All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fixedDepthSearcher2.h
Go to the documentation of this file.
1 /* fixedDepthSearcher2.h
2  */
3 #ifndef _CHECKMATE_FIXED_DEPTH_SERCHER2_H
4 #define _CHECKMATE_FIXED_DEPTH_SERCHER2_H
7 #include "osl/move.h"
8 #include "osl/pieceStand.h"
9 #include "osl/misc/carray.h"
10 #include "osl/misc/align16New.h"
11 
12 namespace osl
13 {
14  class PieceStand;
15  namespace container
16  {
17  class MoveVector;
18  }
19  namespace checkmate
20  {
30 #if OSL_WORDSIZE == 32
31  : public misc::Align16New
32 #endif
33  {
34  private:
35  static const int MAXDEPTH=16;
36  NumEffectState *original_state;
37  CArray<NumEffectState,MAXDEPTH> states;
38  int count;
39  public:
40  FixedDepthSearcher2() : original_state(0), count(0)
41  {
42  }
43  explicit FixedDepthSearcher2(NumEffectState& s)
44  : original_state(&s), count(0)
45  {
46  }
47  void setState(NumEffectState& s)
48  {
49  original_state = &s;
50  }
51  private:
52  void addCount()
53  {
54  count++;
55  }
56  public:
57  int getCount() const
58  {
59  return count;
60  }
61  public:
62  // private: Note: helper の都合
63  template <Player P, bool SetPieces, bool HasGuide>
64  const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
65  template <Player P, bool SetPieces, bool HasGuide>
66  const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
67  template <Player P, bool SetPieces>
68  const ProofDisproof defense(Move last_move,int depth,
69  PieceStand& proof_pieces);
70  private:
74  template <Player P, bool SetPieces>
75  const ProofDisproof defenseEstimation(int depth,Move last_move, PieceStand& proof_pieces,
76  Piece attacker_piece,
77  Square target_position) const;
78  public:
83  template <Player P>
84  const ProofDisproof hasCheckmateMove(int depth, Move& best_move,
85  PieceStand& proof_pieces)
86  {
87  states[depth].copyFrom(*original_state);
88  return attack<P,true,false>(depth, best_move, proof_pieces);
89  }
94  template <Player P>
95  const ProofDisproof hasCheckmateWithGuide(int depth, Move& guide,
96  PieceStand& proof_pieces);
97  template <Player P>
98  const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
99  {
100  PieceStand proof_pieces;
101  states[depth].copyFrom(*original_state);
102  return attack<P,false,false>(depth, best_move, proof_pieces);
103  }
104  template <Player P>
106  {
107  Move checkmate_move;
108  return hasCheckmateMove<P>(depth, checkmate_move);
109  }
110 
118  template <Player P>
119  const ProofDisproof hasEscapeMove(Move last_move,int depth,
120  PieceStand& proof_pieces)
121  {
122  return defense<P,true>(last_move, depth, proof_pieces);
123  }
124  template <Player P>
125  const ProofDisproof hasEscapeMove(Move last_move,int depth)
126  {
127  PieceStand proof_pieces;
128  return defense<P,false>(last_move, depth, proof_pieces);
129  }
135  template <Player P>
136  const ProofDisproof hasEscapeByMove(Move next_move, int depth,
137  Move& check_move,
138  PieceStand& proof_pieces);
139  template <Player P>
140  const ProofDisproof hasEscapeByMove(Move next_move, int depth);
141 
142  const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
143  const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move,
144  PieceStand& proof_pieces);
145  const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move& guide,
146  PieceStand& proof_pieces);
147  const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
148  const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth,
149  Move& check_move,
150  PieceStand& proof_pieces);
151  const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
152 
156  template <Player Defense>
157  void generateBlockingWhenLiberty0(int depth,Piece defense_king, Square attack_from,
159  template <Player Defense>
160  int blockEstimation(Square attack_from, Square defense_king) const;
161  };
162  } // namespace checkmate
163 } // namespace osl
164 
165 #endif /* _CHECKMATE_FIXED_DEPTH_SERCHER2_H */
166 // ;;; Local Variables:
167 // ;;; mode:c++
168 // ;;; c-basic-offset:2
169 // ;;; End: