summaryrefslogtreecommitdiff
path: root/yapf/unittest/test_yapf.h
diff options
context:
space:
mode:
Diffstat (limited to 'yapf/unittest/test_yapf.h')
-rw-r--r--yapf/unittest/test_yapf.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/yapf/unittest/test_yapf.h b/yapf/unittest/test_yapf.h
index ca4b21de0..558ea4667 100644
--- a/yapf/unittest/test_yapf.h
+++ b/yapf/unittest/test_yapf.h
@@ -132,9 +132,9 @@ typedef CTestYapfNodeT<CNodeKey2> CYapfNode2;
template <class Types>
struct CYapfTestBaseT
{
- typedef typename Types::Tpf Tpf;
+ typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
- typedef typename Node::Key Key; ///< key to hash tables
+ typedef typename Node::Key Key; ///< key to hash tables
typedef typename Types::Map Map;
int m_x1, m_y1;
@@ -155,9 +155,13 @@ struct CYapfTestBaseT
m_td1 = td1;
}
+ /// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE char TransportTypeChar() const {return 'T';}
+ /** Called by YAPF to move from the given node to the next tile. For each
+ * reachable trackdir on the new tile creates new node, initializes it
+ * and adds it to the open list by calling Yapf().AddNewNode(n) */
FORCEINLINE void PfFollowNode(Node& org)
{
int x_org = org.m_key.m_x;
@@ -191,6 +195,7 @@ struct CYapfTestBaseT
}
}
+ /// Called when YAPF needs to place origin nodes into open list
FORCEINLINE void PfSetStartupNodes()
{
Node& n1 = Yapf().CreateNewNode();
@@ -201,6 +206,9 @@ struct CYapfTestBaseT
Yapf().AddStartupNode(n1);
}
+ /** Called by YAPF to calculate the cost from the origin to the given node.
+ * Calculates only the cost of given node, adds it to the parent node cost
+ * and stores the result into Node::m_cost member */
FORCEINLINE bool PfCalcCost(Node& n)
{
// base tile cost depending on distance
@@ -216,6 +224,8 @@ struct CYapfTestBaseT
return true;
}
+ /** Called by YAPF to calculate cost estimate. Calculates distance to the destination
+ * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
FORCEINLINE bool PfCalcEstimate(Node& n)
{
int dx = abs(n.m_key.m_x - m_x2);
@@ -227,6 +237,7 @@ struct CYapfTestBaseT
return true;
}
+ /// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(Node& n)
{
bool bDest = (n.m_key.m_x == m_x2) && (n.m_key.m_y == m_y2);