00001
00002
00003 #ifndef OSL_CHECKMATE_FIXED_DEPTH_SERCHER_H
00004 #define OSL_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 checkmate
00014 {
00015 class CheckMoveVector;
00023 class FixedDepthSearcher
00024 {
00025 private:
00026 NumEffectState *state;
00027 int count;
00028 public:
00029 FixedDepthSearcher() : state(0), count(0)
00030 {
00031 }
00032 explicit FixedDepthSearcher(NumEffectState& s)
00033 : state(&s), count(0)
00034 {
00035 }
00036 void setState(NumEffectState& s)
00037 {
00038 state = &s;
00039 }
00040 private:
00041 void addCount()
00042 {
00043 count++;
00044 }
00045 public:
00046 int getCount() const
00047 {
00048 return count;
00049 }
00050 const PieceStand stand(Player P) const
00051 {
00052 return PieceStand(P, *state);
00053 }
00054 public:
00055
00056 template <Player P, bool SetPieces, bool HasGuide>
00057 const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
00058 template <Player P, bool SetPieces, bool HasGuide>
00059 const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
00060 template <Player P, bool SetPieces>
00061 const ProofDisproof defense(Move last_move,int depth,
00062 PieceStand& proof_pieces);
00063 private:
00067 template <Player P, bool SetPieces>
00068 const ProofDisproof defenseEstimation(Move last_move, PieceStand& proof_pieces,
00069 Piece attacker_piece,
00070 Square target_position) const;
00071 public:
00076 template <Player P>
00077 const ProofDisproof hasCheckmateMove(int depth, Move& best_move,
00078 PieceStand& proof_pieces)
00079 {
00080 return attack<P,true,false>(depth, best_move, proof_pieces);
00081 }
00086 template <Player P>
00087 const ProofDisproof hasCheckmateWithGuide(int depth, Move& guide,
00088 PieceStand& proof_pieces);
00089 template <Player P>
00090 const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
00091 {
00092 PieceStand proof_pieces;
00093 return attack<P,false,false>(depth, best_move, proof_pieces);
00094 }
00095 template <Player P>
00096 const ProofDisproof hasCheckmateMove(int depth)
00097 {
00098 Move checkmate_move;
00099 return hasCheckmateMove<P>(depth, checkmate_move);
00100 }
00101
00109 template <Player P>
00110 const ProofDisproof hasEscapeMove(Move last_move,int depth,
00111 PieceStand& proof_pieces)
00112 {
00113 return defense<P,true>(last_move, depth, proof_pieces);
00114 }
00115 template <Player P>
00116 const ProofDisproof hasEscapeMove(Move last_move,int depth)
00117 {
00118 PieceStand proof_pieces;
00119 return defense<P,false>(last_move, depth, proof_pieces);
00120 }
00126 template <Player P>
00127 const ProofDisproof hasEscapeByMove(Move next_move, int depth,
00128 Move& check_move,
00129 PieceStand& proof_pieces);
00130 template <Player P>
00131 const ProofDisproof hasEscapeByMove(Move next_move, int depth);
00132
00133 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
00134 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move,
00135 PieceStand& proof_pieces);
00136 const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move& guide,
00137 PieceStand& proof_pieces);
00138 const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
00139 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth,
00140 Move& check_move,
00141 PieceStand& proof_pieces);
00142 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
00143
00147 template <Player Defense>
00148 void generateBlockingWhenLiberty0(Piece defense_king, Square attack_from,
00149 CheckMoveVector& moves) const;
00150 template <Player Defense>
00151 int blockEstimation(Square attack_from, Square defense_king) const;
00152 };
00153 }
00154 }
00155
00156 #endif
00157
00158
00159
00160