home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 412_01 / src / unisear / tucost.cpp < prev   
Encoding:
C/C++ Source or Header  |  1993-12-28  |  603 b   |  35 lines

  1. #include "tree.h"
  2.  
  3. /*                      UNICOST_TREE_
  4.  
  5.     The constructor passes the start node, goal node and number of
  6.     operators to SEARCH_.
  7.  
  8. */
  9.  
  10. UNICOST_TREE_::UNICOST_TREE_(UNI_NODE_ *start, UNI_NODE_ *goal, int op)
  11.     :SEARCH_(start, goal, op)
  12. {
  13. }
  14.  
  15.  
  16.  
  17. int UNICOST_TREE_::add(NODE_ *succ)
  18. {
  19.     const UNI_NODE_
  20.         *parent;
  21.     UNI_NODE_
  22.         *bsucc = (UNI_NODE_ *) succ;
  23.  
  24.     int
  25.         g;
  26.  
  27.     parent = (UNI_NODE_ *) bsucc->getparent();
  28.  
  29.     g = parent->get_g() + compute_g(*bsucc);
  30.     bsucc->set_g(g);
  31.  
  32.     open.insert(*bsucc);
  33.     return(1);
  34. }
  35.