home *** CD-ROM | disk | FTP | other *** search
/ Desktop Works 1995 - 1996 / desktopworks1995-1996.iso / scrnsave / win_maze / cell.h < prev    next >
C/C++ Source or Header  |  1996-01-01  |  4KB  |  122 lines

  1. #ifndef CELL_H
  2. #define CELL_H
  3.  
  4. //      Each instance of this class represents a room in a maze.
  5.  
  6. class cell
  7.   {
  8.     private:
  9.       char wall_present;
  10. //      Bits representing whether or not a wall is present in a room.
  11. //
  12. //      For square rooms,
  13. //           0x01 represents the north wall,
  14. //           0x02 represents the west wall,
  15. //           0x04 represents the south wall, and
  16. //           0x08 represents the east wall.
  17. //      For hexagonal rooms,
  18. //           0x01 represents the north wall,
  19. //           0x02 represents the northwest wall,
  20. //           0x04 represents the southwest wall, 
  21. //           0x08 represents the south wall.
  22. //           0x10 represents the southeast wall, and
  23. //           0x20 represents the northeast wall.
  24.  
  25.       int  order_to_check_walls;
  26. //      For square rooms, there are 24 (=4!) orders in which the walls may be
  27. // checked.
  28. //      For hexagonal rooms, there are 720 (=6!) orders in which the walls may
  29. // be checked.
  30.  
  31.       char wall_to_check;
  32. //      Number of wall (within the current order) to be checked next.
  33.  
  34.       char mark_on_floor;
  35. //      'M' if room has not been excavated,
  36. //      'S' if room is part of solution (or proposed solution), or
  37. //      ' ' if room has been excavated.
  38.  
  39.       char direction_to_exit;
  40. //      Opposite of direction by which room was first entered.
  41. //      For square rooms,
  42. //           0x01 represents north,
  43. //           0x02 represents west,
  44. //           0x04 represents south, and
  45. //           0x08 represents east.
  46. //      For hexagonal rooms,
  47. //           0x01 represents north,
  48. //           0x02 represents northwest,
  49. //           0x04 represents southwest, 
  50. //           0x08 represents south.
  51. //           0x10 represents southeast, and
  52. //           0x20 represents northeast.
  53.  
  54.     public:
  55.       cell(void)
  56.         {
  57.           wall_to_check='\0';
  58.           mark_on_floor='M';
  59.           wall_present=(char) 0x3f;
  60.         }
  61. //      Rooms are initially filled with mud (i.e., not excavated) and all
  62. // walls are present.
  63.  
  64.       char mark(void) {return mark_on_floor;}
  65. //      'M' for not excavated, ' ' for excavated, 'S' for part of solution.
  66.  
  67.       void knock_down_wall(char wall_num);
  68. //      Changes the bit for the appropriate wall to zero.
  69. //      For square rooms,
  70. //           0 represents the north wall,
  71. //           1 represents the west wall,
  72. //           2 represents the south wall, and
  73. //           3 represents the east wall.
  74. //      For hexagonal rooms,
  75. //           0 represents the north wall,
  76. //           1 represents the northwest wall,
  77. //           2 represents the southwest wall, 
  78. //           3 represents the south wall.
  79. //           4 represents the southeast wall, and
  80. //           5 represents the northeast wall.
  81.  
  82.       void mark_floor(char mark) {mark_on_floor=mark;}
  83. //      Mark made by excavator ('M' for not excavated or ' ' for excavated)
  84. // or solver ('S' for part of proposed solution).
  85.  
  86.       char next_wall_num(void) {return wall_to_check++;}
  87.       void reinitialize(void)
  88.         {
  89.           wall_to_check='\0';
  90.           mark_on_floor='M';
  91.           wall_present=(char) 0x3f;
  92.         }
  93. //     Walls are erected and room is filled with mud.
  94.  
  95.       int  order_to_check(void) {return order_to_check_walls;}
  96.  
  97.       void set_order(int order) {order_to_check_walls=order;}
  98.  
  99.       void zero_wall_to_check(void) {wall_to_check='\0';}
  100.  
  101.       void set_way_out(char way_out) {direction_to_exit=way_out;}
  102.  
  103.       int  wall_up(char wall_num);
  104. //     Returns whether or not a wall is present.
  105. //      For square rooms,
  106. //           0 represents the north wall,
  107. //           1 represents the west wall,
  108. //           2 represents the south wall, and
  109. //           3 represents the east wall.
  110. //      For hexagonal rooms,
  111. //           0 represents the north wall,
  112. //           1 represents the northwest wall,
  113. //           2 represents the southwest wall, 
  114. //           3 represents the south wall.
  115. //           4 represents the southeast wall, and
  116. //           5 represents the northeast wall.
  117.  
  118.       char way_back(void) {return direction_to_exit;}
  119.   };
  120.  
  121. #endif
  122.