home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / GRAPH.ZIP / AI / DEMOS / DEMO3.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-12  |  1.3 KB  |  57 lines

  1. #include <stdio.h>
  2. #include "graph.h"
  3.  
  4.  
  5. /*                     DEMO3
  6.  
  7.     In this problem we solve a 'real' 8-puzzle. Unlike demo1 we're
  8.     not just interested in the position of the empty tile, but want
  9.     to know exactly which tiles have to be moved to transform
  10.     the start configuration into the goal configuration.
  11.  
  12. */
  13.  
  14.  
  15.  
  16. /*                     PNODE
  17.  
  18.     Class PNODE_ defines objects representing a board configuration.
  19.  
  20. */
  21.  
  22. class PNODE_ : public NODE_
  23. {
  24.     public:
  25.         PNODE_(const char *, int empty_x, int empty_y);
  26.         PNODE_(const char *, int, int, int, int);
  27.         int get_x() const;
  28.         int get_y() const;
  29.         const char *get_board() const;
  30.  
  31. // implementation of virtual functions
  32.         int equal(const VOBJECT_ &) const;
  33.         void display() const;
  34.         NODE_ *do_operator(int) const;
  35.     private:
  36.         PNODE_
  37.             *do_left() const,
  38.             *do_right() const,
  39.             *do_up() const,
  40.             *do_down() const;
  41.             int compare_board(const char *) const;
  42.         int
  43.             x,                    // coordinates of empty tile.
  44.             y;
  45.         char
  46.             board[3][3];          // array to represent board configuration
  47. };
  48.  
  49.  
  50. class PUZZLE_ : public DEPTH_GRAPH_
  51. {
  52.     public:
  53.         PUZZLE_(PNODE_ *start, PNODE_ *target);
  54. };
  55.  
  56.  
  57.