All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
quiescenceLog.cc
Go to the documentation of this file.
1 /* quiescenceLog.cc
2  */
5 #include <boost/scoped_ptr.hpp>
6 #include <fstream>
7 #include <iostream>
8 
9 namespace
10 {
11  boost::scoped_ptr<std::ofstream> os;
12 } // anonymous namespace
13 
14 std::ostream* osl::search::QuiescenceLog::
15 os()
16 {
17  return ::os.get();
18 }
19 
21 init(const char *filename)
22 {
23  ::os.reset(new std::ofstream(filename));
24 }
25 
28 {
29  ::os.reset();
30 }
31 
33 enter(const SimpleState& state)
34 {
35  if (os())
36  {
37  *os() << '*' << "new node\n";
38  *os() << state;
39  }
40 }
41 
43 pushMove(int depth, Move move, const QuiescenceRecord *record)
44 {
45  if (os())
46  {
47  *os() << std::string(2+std::max(0,QSearchTraits::MaxDepth-depth), '*')
48  << move << "\n" << std::flush;
49  if (record)
50  record->dump(*os());
51  }
52 }
53 
55 staticValue(int depth, int value)
56 {
57  if (os())
58  *os() << std::string(2+std::max(0,QSearchTraits::MaxDepth-depth), '*')
59  <<" static " << value << "\n" << std::flush;
60 }
61 
63 node(int depth, int alpha, int beta, int result)
64 {
65  if (os())
66  *os() << std::string(1+std::max(0,QSearchTraits::MaxDepth-depth), '*')
67  << alpha << " " << beta << " => " << result << "\n" << std::flush;
68 };
69 
70 
71 /* ------------------------------------------------------------------------- */
72 // ;;; Local Variables:
73 // ;;; mode:c++
74 // ;;; c-basic-offset:2
75 // ;;; End: