Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgSearchTracer.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgSearchTracer.h
00003     Trace search for SgSearch.
00004 
00005     SgSearchTracer stores the whole search in a game tree using SgNode's.
00006 */
00007 //----------------------------------------------------------------------------
00008 
00009 #ifndef SG_SEARCHTRACER_H
00010 #define SG_SEARCHTRACER_H
00011 
00012 #include "SgBlackWhite.h"
00013 #include "SgMove.h"
00014 #include "SgNode.h"
00015 
00016 //----------------------------------------------------------------------------
00017 
00018 /** Traces a search. */
00019 class SgSearchTracer
00020 {
00021 public:
00022     SgSearchTracer(SgNode* root);
00023     
00024     virtual ~SgSearchTracer();
00025 
00026     /** Adds the given move as a new node to the trace tree and goes
00027         to that node. Doesn't do anything if m_traceNode is 0. */
00028     void AddTraceNode(SgMove move, SgBlackWhite player);
00029 
00030     /** Current node */
00031     SgNode* TraceNode() const;
00032 
00033     /** Add comment to current tracenode */
00034     void TraceComment(const char* comment) const;
00035     
00036     void StartOfDepth(int depth);
00037 
00038      /** Adds move property to node (game-dependent). 
00039          The default implementation stores the move in a SgMoveProp.
00040          Override this method for other games.
00041      */
00042     virtual void AddMoveProp(SgNode* node, SgMove move,
00043                              SgBlackWhite player);
00044     
00045     /** Add value as a comment to current tracenode */
00046     void TraceValue(int value, SgBlackWhite toPlay) const;
00047 
00048     /** Add value and text as a comment to current tracenode */
00049     void TraceValue(int value, SgBlackWhite toPlay,
00050                     const char* comment, bool isExact) const;
00051 
00052     /** Go one move up in the trace tree.
00053         Don't do anything if m_traceNode is null.
00054         To be called from the client's TakeBack method.
00055     */
00056     void TakeBackTraceNode();
00057 
00058     /** Is tracing on? Default implementation always returns true. */
00059     virtual bool TraceIsOn() const;
00060 
00061     /** Creates a new root node for tracing. Override to add information */
00062     virtual void InitTracing(const std::string& type);
00063 
00064     /** Move trace tree to a subtree of toNode, and set m_traceNode = 0 */
00065     void AppendTrace(SgNode* toNode);
00066 
00067 protected:
00068     /** Current node in tracing. */
00069     SgNode* m_traceNode;
00070 
00071 private:
00072     /** Not implemented */
00073     SgSearchTracer(const SgSearchTracer&);
00074 
00075     /** Not implemented */
00076     SgSearchTracer& operator=(const SgSearchTracer&);
00077 };
00078 
00079 inline SgNode* SgSearchTracer::TraceNode() const
00080 {
00081     return m_traceNode;
00082 }
00083 
00084 inline bool SgSearchTracer::TraceIsOn() const
00085 {
00086     return true;
00087 }
00088 
00089 //----------------------------------------------------------------------------
00090 
00091 #endif // SG_SEARCH_H


17 Jun 2010 Doxygen 1.4.7