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

  1. #include "nodes.h"
  2.  
  3. /*            AONODE_
  4.  
  5.     This constructor sets the type of the node by default to OR.
  6.  
  7. */
  8.  
  9. AONODE_::AONODE_()
  10. {
  11.     type = OR;
  12.     n_left = 0;
  13.     solved = DUNNO;
  14. }
  15.  
  16.  
  17.  
  18. /*            AONODE_
  19.  
  20.     This constructor sets the type of the node to the specified value.
  21.  
  22. */
  23.  
  24. AONODE_::AONODE_(int t)
  25. {
  26.     type = t;
  27.     n_left = 0;
  28.     solved = DUNNO;
  29. }
  30.  
  31.  
  32.  
  33. /*                        AONODE_
  34.  
  35.     This constructor sets the type of the node to the specified value,
  36.     it also sets n_left to the specified value.
  37.  
  38. */
  39.  
  40. AONODE_::AONODE_(int t, int l)
  41. {
  42.     type = t;
  43.     n_left = l;
  44.     solved = DUNNO;
  45. }
  46.  
  47.  
  48.  
  49. /*            DECN_LEFT
  50.  
  51.     Decreases the number of successors left by one.
  52.  
  53. */
  54.  
  55. void AONODE_::decn_left()
  56. {
  57.     n_left--;
  58. }
  59.  
  60.  
  61.  
  62. /*            GETTYPE
  63.  
  64.     Returns type of node: AND or OR.
  65.  
  66. */
  67.  
  68. int AONODE_::gettype() const
  69. {
  70.     return(type);
  71. }
  72.  
  73.  
  74. /*            SETTYPE
  75.  
  76.     Sets type of node to t: AND or OR.
  77.  
  78. */
  79.  
  80. void AONODE_::settype(int t)
  81. {
  82.     type = t;
  83. }
  84.  
  85.  
  86.  
  87. /*            SETSOLVED
  88.  
  89.     Sets the solved status of node to s: SOLVED, UNSOLVABLE or DUNNO.
  90.  
  91. */
  92.  
  93. void AONODE_::setsolved(int s)
  94. {
  95.     solved = s;
  96. }
  97.  
  98.  
  99.  
  100. /*            GETN_LEFT
  101.  
  102.     Returns the number of successors left.
  103.  
  104. */
  105.  
  106. int AONODE_::getn_left() const
  107. {
  108.     return(n_left);
  109. }
  110.  
  111.  
  112.  
  113. /*            GETSOLVED
  114.  
  115.     Returns the solved status of node: SOLVED, UNSOLVABLE, or DUNNO.
  116.  
  117. */
  118.  
  119. int AONODE_::getsolved() const
  120. {
  121.     return(solved);
  122. }
  123.  
  124.  
  125.  
  126. /*            INCN_LEFT
  127.  
  128.     Increase the number of successors left by one.
  129.  
  130. */
  131.  
  132. void AONODE_::incn_left()
  133. {
  134.     n_left++;
  135. }
  136.  
  137.