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 {
00027 class FixedDepthSearcher
00028 {
00029 private:
00030 NumEffectState *state;
00031 int count;
00032 public:
00033 FixedDepthSearcher() : state(0), count(0)
00034 {
00035 }
00036 explicit FixedDepthSearcher(NumEffectState& s)
00037 : state(&s), count(0)
00038 {
00039 }
00040 void setState(NumEffectState& s)
00041 {
00042 state = &s;
00043 }
00044 private:
00045 void addCount()
00046 {
00047 count++;
00048 }
00049 public:
00050 int getCount() const
00051 {
00052 return count;
00053 }
00054 const PieceStand stand(Player P) const
00055 {
00056 return PieceStand(P, *state);
00057 }
00058 public:
00059
00060 template <Player P, bool SetPieces, bool HasGuide>
00061 const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
00062 template <Player P, bool SetPieces, bool HasGuide>
00063 const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
00064 template <Player P, bool SetPieces>
00065 const ProofDisproof defense(Move last_move,int depth,
00066 PieceStand& proof_pieces);
00067 private:
00071 template <Player P, bool SetPieces>
00072 const ProofDisproof defenseEstimation(Move last_move, PieceStand& proof_pieces,
00073 Piece attacker_piece,
00074 Position target_position) const;
00075 public:
00080 template <Player P>
00081 const ProofDisproof hasCheckmateMove(int depth, Move& best_move,
00082 PieceStand& proof_pieces)
00083 {
00084 return attack<P,true,false>(depth, best_move, proof_pieces);
00085 }
00090 template <Player P>
00091 const ProofDisproof hasCheckmateWithGuide(int depth, Move& guide,
00092 PieceStand& proof_pieces);
00093 template <Player P>
00094 const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
00095 {
00096 PieceStand proof_pieces;
00097 return attack<P,false,false>(depth, best_move, proof_pieces);
00098 }
00099 template <Player P>
00100 const ProofDisproof hasCheckmateMove(int depth)
00101 {
00102 Move checkmate_move;
00103 return hasCheckmateMove<P>(depth, checkmate_move);
00104 }
00105
00113 template <Player P>
00114 const ProofDisproof hasEscapeMove(Move last_move,int depth,
00115 PieceStand& proof_pieces)
00116 {
00117 return defense<P,true>(last_move, depth, proof_pieces);
00118 }
00119 template <Player P>
00120 const ProofDisproof hasEscapeMove(Move last_move,int depth)
00121 {
00122 PieceStand proof_pieces;
00123 return defense<P,false>(last_move, depth, proof_pieces);
00124 }
00130 template <Player P>
00131 const ProofDisproof hasEscapeByMove(Move next_move, int depth,
00132 Move& check_move,
00133 PieceStand& proof_pieces);
00134 template <Player P>
00135 const ProofDisproof hasEscapeByMove(Move next_move, int depth);
00136
00137 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
00138 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move,
00139 PieceStand& proof_pieces);
00140 const ProofDisproof hasCheckmateWithGuideOfTurn(int depth, Move& guide,
00141 PieceStand& proof_pieces);
00142 const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
00143 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth,
00144 Move& check_move,
00145 PieceStand& proof_pieces);
00146 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
00147
00151 template <Player Defense>
00152 void generateBlockingWhenLiberty0(Piece defense_king, Position attack_from,
00153 container::MoveVector& moves) const;
00154 template <Player Defense>
00155 int blockEstimation(Position attack_from, Position defense_king) const;
00156 };
00157 }
00158 }
00159
00160 #endif
00161
00162
00163
00164