All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dualDfpn.h
Go to the documentation of this file.
1 /* dualDfpn.h
2  */
3 #ifndef OSL_DUALDFPN_H
4 #define OSL_DUALDFPN_H
7 #include "osl/hash/hashKey.h"
8 #include "osl/pathEncoding.h"
10 #include <boost/cstdint.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <boost/scoped_ptr.hpp>
13 #include <cstddef>
14 #include <limits>
15 
16 #ifdef OSL_SMP
17 # ifndef OSL_DFPN_SMP
18 # define OSL_DFPN_SMP
19 # endif
20 #endif
21 
22 namespace osl
23 {
24  class RepetitionCounter;
25  namespace checkmate
26  {
27  class Dfpn;
28  class DfpnTable;
30  class DualDfpn
31  {
32  struct Shared;
33  struct Local;
34  struct OraclePool;
35  boost::shared_ptr<Shared> shared;
36  boost::scoped_ptr<Local> local;
37  public:
38  explicit DualDfpn(uint64_t ignored=std::numeric_limits<uint64_t>::max());
39  DualDfpn(const DualDfpn& src);
40  ~DualDfpn();
41 
42  void setRootPlayer(Player);
43  template <Player P>
44  ProofDisproof findProof(int node_limit, const NumEffectState& state,
45  const HashKey& key, const PathEncoding& path,
46  Move& best_move, Move last_move=Move::INVALID());
52  template <Player P>
53  bool isWinningState(int node_limit, const NumEffectState& state,
54  const HashKey& key, const PathEncoding& path,
55  Move& best_move, Move last_move=Move::INVALID())
56  {
57  return findProof(node_limit, state, key, path, best_move, last_move)
59  }
60  bool isWinningState(int node_limit, const NumEffectState& state,
61  const HashKey& key, const PathEncoding& path,
62  Move& best_move, Move last_move=Move::INVALID());
63  ProofDisproof findProof(int node_limit, const NumEffectState& state,
64  const HashKey& key, const PathEncoding& path,
65  Move& best_move, Move last_move=Move::INVALID());
66 #ifdef OSL_DFPN_SMP
67 
71  template <Player P>
72  bool isWinningStateParallel(int node_limit, const NumEffectState& state,
73  const HashKey& key, const PathEncoding& path,
74  Move& best_move, Move last_move=Move::INVALID());
75  bool isWinningStateParallel(int node_limit, const NumEffectState& state,
76  const HashKey& key, const PathEncoding& path,
77  Move& best_move, Move last_move=Move::INVALID());
78 #endif
79  template <Player P>
80  bool isLosingState(int node_limit, const NumEffectState& state,
81  const HashKey& key, const PathEncoding& path,
82  Move last_move=Move::INVALID());
83  bool isLosingState(int node_limit, const NumEffectState& state,
84  const HashKey& key, const PathEncoding& path,
85  Move last_move=Move::INVALID());
86 
87  void runGC(bool verbose=false, size_t memory_use_ratio_1000=0);
88 
89  // debug
90  void setVerbose(int level=1);
91  int distance(Player attack, const HashKey& key);
92  size_t mainNodeCount() const;
93  size_t totalNodeCount() const;
94  void writeRootHistory(const RepetitionCounter& counter,
95  const MoveStack& moves,
96  const SimpleState& state, Player attack);
97  const DfpnTable& table(Player) const;
98  private:
99  Dfpn& prepareDfpn(Player attack);
100  Dfpn& prepareDfpnSmall(Player attack);
101  };
102  }
103  using checkmate::DualDfpn;
104 }
105 
106 #endif /* OSL_DUALDFPN_H */
107 // ;;; Local Variables:
108 // ;;; mode:c++
109 // ;;; c-basic-offset:2
110 // ;;; End: