00001
00002
00003 #ifndef OSL_DUALDFPN_H
00004 #define OSL_DUALDFPN_H
00005 #include "osl/state/numEffectState.h"
00006 #include "osl/hash/hashKey.h"
00007 #include "osl/pathEncoding.h"
00008 #include "osl/container/moveStack.h"
00009 #include <boost/cstdint.hpp>
00010 #include <boost/shared_ptr.hpp>
00011 #include <boost/scoped_ptr.hpp>
00012 #include <cstddef>
00013 #include <limits>
00014
00015 #ifdef OSL_SMP
00016 # ifndef OSL_DFPN_SMP
00017 # define OSL_DFPN_SMP
00018 # endif
00019 #endif
00020
00021 namespace osl
00022 {
00023 class RepetitionCounter;
00024 namespace checkmate
00025 {
00026 class Dfpn;
00027 class DfpnTable;
00029 class DualDfpn
00030 {
00031 struct Shared;
00032 struct Local;
00033 struct OraclePool;
00034 boost::shared_ptr<Shared> shared;
00035 boost::scoped_ptr<Local> local;
00036 public:
00037 explicit DualDfpn(uint64_t ignored=std::numeric_limits<uint64_t>::max());
00038 DualDfpn(const DualDfpn& src);
00039 ~DualDfpn();
00040
00041 void setRootPlayer(Player);
00047 template <Player P>
00048 bool isWinningState(int node_limit, const NumEffectState& state,
00049 const HashKey& key, const PathEncoding& path,
00050 Move& best_move, Move last_move=Move::INVALID());
00051 bool isWinningState(int node_limit, const NumEffectState& state,
00052 const HashKey& key, const PathEncoding& path,
00053 Move& best_move, Move last_move=Move::INVALID());
00054 #ifdef OSL_DFPN_SMP
00055
00059 template <Player P>
00060 bool isWinningStateParallel(int node_limit, const NumEffectState& state,
00061 const HashKey& key, const PathEncoding& path,
00062 Move& best_move, Move last_move=Move::INVALID());
00063 bool isWinningStateParallel(int node_limit, const NumEffectState& state,
00064 const HashKey& key, const PathEncoding& path,
00065 Move& best_move, Move last_move=Move::INVALID());
00066 #endif
00067 template <Player P>
00068 bool isLosingState(int node_limit, NumEffectState& state,
00069 const HashKey& key, const PathEncoding& path,
00070 Move last_move=Move::INVALID());
00071 bool isLosingState(int node_limit, NumEffectState& state,
00072 const HashKey& key, const PathEncoding& path,
00073 Move last_move=Move::INVALID());
00074
00075 void runGC();
00076
00077
00078 void setVerbose(int level=1);
00079 int distance(Player attack, const HashKey& key);
00080 size_t mainNodeCount() const;
00081 size_t totalNodeCount() const;
00082 void writeRootHistory(const RepetitionCounter& counter,
00083 const MoveStack& moves,
00084 const SimpleState& state, Player attack);
00085 const DfpnTable& table(Player) const;
00086 private:
00087 Dfpn& prepareDfpn(Player attack);
00088 Dfpn& prepareDfpnSmall(Player attack);
00089 };
00090 }
00091 using checkmate::DualDfpn;
00092 }
00093
00094 #endif
00095
00096
00097
00098