From ed48b38619492a4018ac014d203718db689f69b2 Mon Sep 17 00:00:00 2001 From: KUDr Date: Mon, 29 May 2006 18:39:42 +0000 Subject: (svn r5018) [YAPF] Added some comments to YAPF implementation. --- yapf/unittest/test_yapf.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'yapf/unittest') 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 CYapfNode2; template 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(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); -- cgit v1.2.3-70-g09d2