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/numEffectState.h"
00007 #include "osl/bits/king8Info.h"
00008 #include "osl/bits/pieceStand.h"
00009
00010 namespace osl
00011 {
00012 namespace checkmate
00013 {
00014 struct NoProofPieces
00015 {
00016 static void setAttackLeaf(Move , PieceStand& ) {
00017 }
00018 static void attack(Move , PieceStand, PieceStand& ) {
00019 }
00020 static void setLeaf(const NumEffectState&, Player, PieceStand, PieceStand&) {
00021 }
00022 static void clear(PieceStand& ) {
00023 }
00024 static void updateMax(PieceStand , PieceStand& ) {
00025 }
00026 static void addMonopolizedPieces(const NumEffectState&, Player, PieceStand,
00027 PieceStand&) {
00028 }
00029 static ProofDisproof attackEstimation(const NumEffectState&, Player, King8Info) {
00030 return ProofDisproof();
00031 }
00032 };
00040 class FixedDepthSearcher
00041 {
00042 protected:
00043 NumEffectState *state;
00044 int count;
00045 public:
00046 FixedDepthSearcher() : state(0), count(0)
00047 {
00048 }
00049 explicit FixedDepthSearcher(NumEffectState& s)
00050 : state(&s), count(0)
00051 {
00052 }
00053 void setState(NumEffectState& s)
00054 {
00055 state = &s;
00056 }
00057 private:
00058 void addCount()
00059 {
00060 count++;
00061 }
00062 public:
00063 int getCount() const
00064 {
00065 return count;
00066 }
00067 const PieceStand stand(Player P) const
00068 {
00069 return PieceStand(P, *state);
00070 }
00071 public:
00072
00073 template <Player P, class SetPieces, bool HasGuide>
00074 const ProofDisproof attack(int depth, Move& best_move, PieceStand& proof_pieces);
00075 template <Player P, class SetPieces, bool HasGuide>
00076 const ProofDisproof attackMayUnsafe(int depth, Move& best_move, PieceStand& proof_pieces);
00077 template <Player P, class SetPieces>
00078 const ProofDisproof defense(Move last_move,int depth,
00079 PieceStand& proof_pieces);
00080 private:
00084 template <Player P, class SetPieces>
00085 const ProofDisproof defenseEstimation(Move last_move, PieceStand& proof_pieces,
00086 Piece attacker_piece,
00087 Square target_position) const;
00088 public:
00089 template <Player P>
00090 const ProofDisproof hasCheckmateMove(int depth,Move& best_move)
00091 {
00092 PieceStand proof_pieces;
00093 return attack<P,NoProofPieces,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
00102 template <Player P>
00103 const ProofDisproof hasEscapeMove(Move last_move,int depth)
00104 {
00105 PieceStand proof_pieces;
00106 return defense<P,NoProofPieces>(last_move, depth, proof_pieces);
00107 }
00108 template <Player P>
00109 const ProofDisproof hasEscapeByMove(Move next_move, int depth);
00110
00111 const ProofDisproof hasCheckmateMoveOfTurn(int depth,Move& best_move);
00112 const ProofDisproof hasEscapeMoveOfTurn(Move last_move,int depth);
00113 const ProofDisproof hasEscapeByMoveOfTurn(Move next_move, int depth);
00114
00118 template <Player Defense>
00119 void generateBlockingWhenLiberty0(Piece defense_king, Square attack_from,
00120 CheckMoveVector& moves) const;
00121 template <Player Defense>
00122 int blockEstimation(Square attack_from, Square defense_king) const;
00123 };
00124 }
00125 }
00126
00127 #endif
00128
00129
00130
00131