solvemap_astar.hh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #ifndef G1_SOLVEMAP_BREADTH_HH
  9. #define G1_SOLVEMAP_BREADTH_HH
  10. #include "arch.hh"
  11. #include "memory/array.hh"
  12. #include "math/num_type.hh"
  13. #include "map_cell.hh"
  14. #include <string.h>
  15. class g1_block_map_class;
  16. class g1_astar_map_solver_class
  17. {
  18. public:
  19. class cell
  20. {
  21. public:
  22. w16 x,y;
  23. i4_float length;
  24. i4_float hint;
  25. cell() {}
  26. cell(w16 x, w16 y, i4_float length, i4_float hint) : x(x), y(y), length(length), hint(hint) {}
  27. cell(const cell &a) : x(a.x), y(a.y), length(a.length), hint(a.hint) {}
  28. };
  29. protected:
  30. w16 wx, wy;
  31. w16 dest_x, dest_y;
  32. // Breadth first Queue
  33. i4_array<cell> heap;
  34. void clear_heap() { heap.clear(); }
  35. i4_bool add_link(w16 from_x,w16 from_y, w16 x,w16 y, i4_float length);
  36. i4_bool add_step_link(w16 from_x,w16 from_y, w16 x,w16 y, i4_float length);
  37. i4_bool add_path_link(w16 from_x,w16 from_y, w16 x,w16 y, i4_float length);
  38. i4_bool get_next_cell(w16 &x,w16 &y,i4_float &length);
  39. void clear_solve();
  40. public:
  41. enum { VISITED=g1_map_cell_class::SCRATCH1, OK=g1_map_cell_class::SCRATCH2 };
  42. g1_astar_map_solver_class() : heap(2048,1024) {}
  43. virtual i4_bool path_solve(i4_float startx, i4_float starty, i4_float destx, i4_float desty,
  44. i4_float *point, w16 &points);
  45. };
  46. #endif
  47. //{{{ Emacs Locals
  48. // Local Variables:
  49. // folded-file: t
  50. // End:
  51. //}}}