dualDfpn.h
Go to the documentation of this file.
00001 /* dualDfpn.h
00002  */
00003 #ifndef OSL_DUALDFPN_H
00004 #define OSL_DUALDFPN_H
00005 #include "osl/state/numEffectState.h"
00006 #include "osl/checkmate/proofDisproof.h"
00007 #include "osl/hash/hashKey.h"
00008 #include "osl/pathEncoding.h"
00009 #include "osl/container/moveStack.h"
00010 #include <boost/cstdint.hpp>
00011 #include <boost/shared_ptr.hpp>
00012 #include <boost/scoped_ptr.hpp>
00013 #include <cstddef>
00014 #include <limits>
00015 
00016 #ifdef OSL_SMP
00017 #  ifndef OSL_DFPN_SMP
00018 #    define OSL_DFPN_SMP
00019 #  endif
00020 #endif
00021 
00022 namespace osl
00023 {
00024   class RepetitionCounter;
00025   namespace checkmate
00026   {
00027     class Dfpn;
00028     class DfpnTable;
00030     class DualDfpn
00031     {
00032       struct Shared;
00033       struct Local;
00034       struct OraclePool;
00035       boost::shared_ptr<Shared> shared;
00036       boost::scoped_ptr<Local> local;
00037     public:
00038       explicit DualDfpn(uint64_t ignored=std::numeric_limits<uint64_t>::max());
00039       DualDfpn(const DualDfpn& src);
00040       ~DualDfpn();
00041 
00042       void setRootPlayer(Player);
00043       template <Player P>
00044       ProofDisproof findProof(int node_limit, const NumEffectState& state, 
00045                               const HashKey& key, const PathEncoding& path,
00046                               Move& best_move, Move last_move=Move::INVALID());
00052       template <Player P>
00053       bool isWinningState(int node_limit, const NumEffectState& state, 
00054                           const HashKey& key, const PathEncoding& path,
00055                           Move& best_move, Move last_move=Move::INVALID())
00056       {
00057         return findProof(node_limit, state, key, path, best_move, last_move)
00058           .isCheckmateSuccess();
00059       }
00060       bool isWinningState(int node_limit, const NumEffectState& state, 
00061                           const HashKey& key, const PathEncoding& path,
00062                           Move& best_move, Move last_move=Move::INVALID());
00063       ProofDisproof findProof(int node_limit, const NumEffectState& state, 
00064                               const HashKey& key, const PathEncoding& path,
00065                               Move& best_move, Move last_move=Move::INVALID());
00066 #ifdef OSL_DFPN_SMP
00067 
00071       template <Player P>
00072       bool isWinningStateParallel(int node_limit, const NumEffectState& state, 
00073                                   const HashKey& key, const PathEncoding& path,
00074                                   Move& best_move, Move last_move=Move::INVALID());
00075       bool isWinningStateParallel(int node_limit, const NumEffectState& state, 
00076                                   const HashKey& key, const PathEncoding& path,
00077                                   Move& best_move, Move last_move=Move::INVALID());
00078 #endif
00079       template <Player P>
00080       bool isLosingState(int node_limit, const NumEffectState& state, 
00081                          const HashKey& key, const PathEncoding& path,
00082                          Move last_move=Move::INVALID());
00083       bool isLosingState(int node_limit, const NumEffectState& state, 
00084                          const HashKey& key, const PathEncoding& path,
00085                          Move last_move=Move::INVALID());
00086 
00087       void runGC(bool verbose=false, size_t memory_use_ratio_1000=0);
00088 
00089       // debug
00090       void setVerbose(int level=1);
00091       int distance(Player attack, const HashKey& key);
00092       size_t mainNodeCount() const;
00093       size_t totalNodeCount() const;
00094       void writeRootHistory(const RepetitionCounter& counter,
00095                             const MoveStack& moves,
00096                             const SimpleState& state, Player attack);
00097       const DfpnTable& table(Player) const;
00098     private:
00099       Dfpn& prepareDfpn(Player attack);
00100       Dfpn& prepareDfpnSmall(Player attack);
00101     };
00102   }
00103   using checkmate::DualDfpn;
00104 }
00105 
00106 #endif /* OSL_DUALDFPN_H */
00107 // ;;; Local Variables:
00108 // ;;; mode:c++
00109 // ;;; c-basic-offset:2
00110 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines