home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / GRAPH.ZIP / AI / SRC / NODES / UNODE.CPP < prev   
Encoding:
C/C++ Source or Header  |  1994-08-12  |  814 b   |  55 lines

  1. #include "nodes.h"
  2.  
  3. /*            UNI_NODE_
  4.  
  5.     The constructor sets the initial value of G to 0.
  6.  
  7. */
  8.  
  9. UNI_NODE_::UNI_NODE_()
  10. {
  11.     g = 0;
  12. }
  13.  
  14.  
  15.  
  16. /*            GET_G
  17.  
  18.     Returns node's G-value.
  19.  
  20. */
  21.  
  22. int UNI_NODE_::get_g() const
  23. {
  24.     return(g);
  25. }
  26.  
  27.  
  28. /*            SET_G
  29.  
  30.     Sets node's G-value.
  31.  
  32. */
  33.  
  34. void UNI_NODE_::set_g(int val)
  35. {
  36.     g = val;
  37. }
  38.  
  39.  
  40.  
  41. /*            EVAL
  42.  
  43.     This function determines the order of two nodes based on their
  44.     g-values. If node A has a lower g-value than node B this means
  45.     that node A ranks before node B (nodes are stored in order of
  46.     ascending g-values because we are looking for the cheapest path,
  47.     i.e, the node with the lowest g-value so far).
  48.  
  49. */
  50.  
  51. int UNI_NODE_::eval(const SVOBJECT_ &other) const
  52. {
  53.     return(g - ((UNI_NODE_ &)other).get_g());
  54. }
  55.