00001
00002
00003 #ifndef _CHECKMATE_FIXED_DEPTH_SERCHER_H
00004 #define _CHECKMATE_FIXED_DEPTH_SERCHER_H
00005 #include "osl/checkmate/proofDisproof.h"
00006 #include "osl/state/numEffectState.h"
00007 #include "osl/move.h"
00008 #include "osl/pieceStand.h"
00009
00010 namespace osl
00011 {
00012 class PieceStand;
00013 namespace container
00014 {
00015 class MoveVector;
00016 }
00017 namespace checkmate
00018 {
00026 class FixedDepthSearcher
00027 {
00028 private:
00029 NumEffectState *state;
00030 int count;
00031 public:
00032 FixedDepthSearcher() : state(0), count(0)
00033 {
00034 }
00035 explicit FixedDepthSearcher(NumEffectState& s)
00036 : state(&s), count(0)
00037 {
00038 }
00039 void setState(NumEffectState& s)
00040 {
00041 state = &s;
00042 }
00043 private:
00044 void addCount()
00045 {
00046 count++;
00047 }
00048 public:
00049 int getCount() const
00050 {
00051 return count;
00052 }
00053 const PieceStand stand(Player P) const
00054 {
00055 return PieceStand(P, *state);
00056 }
00057 public:
00058
00059 template <Player P, bool SetPieces, bool HasGuide>
00060 const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
00061 template <Player P, bool SetPieces, bool HasGuide>
00062 const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
00063 template <Player P, bool SetPieces>
00064 const ProofDisproof defense(Move last_move,int depth,
00065 PieceStand& proof_pieces);
00066 private:
00070 template <Player P, bool SetPieces>
00071 const ProofDisproof defenseEstimation(Move last_move, PieceStand& proof_pieces,
00072 Piece attacker_piece,
00073 Position target_position) const;
00074 public:
00079 template <Player P>
00080 const ProofDisproof hasCheckmateMove(int depth, Move& best_move,
00081 PieceStand& proof_pieces)
00082 {
00083 return attack<P,true,false>(depth, best_move, proof_pieces);
00084 }
00089 template <Player P>
00090 const ProofDisproof hasCheckmateWithGuide(int depth, Move& guide,
00091 PieceStand& proof_pieces);
00092 template <Player P>
00093 const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
00094 {
00095 PieceStand proof_pieces;
00096 return attack<P,false,false>(depth, best_move, proof_pieces);
00097 }
00098 template <Player P>
00099 const ProofDisproof hasCheckmateMove(int depth)
00100 {
00101 Move checkmate_move;
00102 return hasCheckmateMove<P>(depth, checkmate_move);
00103 }
00104
00112 template <Player P>
00113 const ProofDisproof hasEscapeMove(Move last_move,int depth,
00114 PieceStand& proof_pieces)
00115 {
00116 return defense<P,true>(last_move, depth, proof_pieces);
00117 }
00118 template <Player P>
00119 const ProofDisproof hasEscapeMove(Move last_move,int depth)
00120 {
00121 PieceStand proof_pieces;
00122 return defense<P,false>(last_move, depth, proof_pieces);
00123 }
00129 template <Player P>
00130 const ProofDisproof hasEscapeByMove(Move next_move, int depth,
00131 Move& check_move,
00132 PieceStand& proof_pieces);
00133 template <Player P>
00134 const ProofDisproof hasEscapeByMove(Move next_move, int depth);
00135
00136 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
00137 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move,
00138 PieceStand& proof_pieces);
00139 const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move& guide,
00140 PieceStand& proof_pieces);
00141 const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
00142 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth,
00143 Move& check_move,
00144 PieceStand& proof_pieces);
00145 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
00146
00150 template <Player Defense>
00151 void generateBlockingWhenLiberty0(Piece defense_king, Position attack_from,
00152 container::MoveVector& moves) const;
00153 template <Player Defense>
00154 int blockEstimation(Position attack_from, Position defense_king) const;
00155 };
00156 }
00157 }
00158
00159 #endif
00160
00161
00162
00163