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

  1. #include "tree.h"
  2.  
  3. /*            AOBREADTH_TREE_
  4.  
  5.     The constructor just passes the start node and number of operators
  6.     on to AOSEARCH_.
  7.  
  8. */
  9.  
  10. AOBREADTH_TREE_::AOBREADTH_TREE_(AONODE_ *start, int op)
  11.     :AOSEARCH_(start, op)
  12. {
  13. }
  14.  
  15.  
  16.  
  17. /*                    ADD
  18.  
  19.     This routine adds nodes to the search tree (it adds them to
  20.     the TAIL of open). Nodes of type AND get special treatment: they
  21.     are not meant to be stored on open, but each of its successors is.
  22.  
  23. */  
  24.  
  25. void AOBREADTH_TREE_::add(AONODE_ *succ)
  26. {
  27.     AONODE_
  28.     *node;
  29.     int
  30.     i,
  31.     num;
  32.  
  33.     if (succ->gettype() == AND)
  34.     {
  35.         num = ((ANDNODE_ *)succ)->getn_nodes();
  36.     for (i = 0 ;i < num; i++)    /* put all successors on open */
  37.     {
  38.         node = ((ANDNODE_ *)succ)->getsucc(i);
  39.         node->setparent(succ);
  40.         open.addtotail(*node);
  41.     }
  42.     }
  43.     else
  44.     open.addtotail(*succ);
  45. }
  46.