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

  1. #include "nodes.h"
  2.  
  3. /*            BEST_NODE_
  4.  
  5.     The constructor sets the node's F-value to 0.
  6.  
  7. */
  8.  
  9. BEST_NODE_::BEST_NODE_()
  10. {
  11.     f = 0;
  12. }
  13.  
  14.  
  15.  
  16. /*            GET_F
  17.  
  18.     Return F-value of node.
  19.  
  20. */
  21.  
  22. int BEST_NODE_::get_f() const
  23. {
  24.     return(f);
  25. }
  26.  
  27.  
  28. /*            SET_F
  29.  
  30.     Set F-value of node.
  31. */
  32.  
  33. void BEST_NODE_::set_f(int val)
  34. {
  35.     f = val;
  36. }
  37.  
  38.  
  39.  
  40. /*                     EVAL
  41.  
  42.     Determines the order of two nodes based on their f-values, i.e., 
  43.     if node A has got a lower f-value than node B this means that node A
  44.     ranks before B (nodes are ordered in order of ascending f-values
  45.     because a lower f-value means that the node is closer to the goal).
  46.  
  47. */
  48.  
  49. int BEST_NODE_::eval(const SVOBJECT_ &other) const
  50. {
  51.     return(f - ((BEST_NODE_ &)other).get_f());
  52. }
  53.