Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public class Astar {
  2. static final int MONSTER = 4;
  3. static final int PUDDLE = 3;
  4. static final int TARGET = 2;
  5. static final int WALL = 1;
  6. public static void main(String[] args) {
  7. char[][] maze = {
  8. { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
  9. { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
  10. { ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ' },
  11. { ' ', ' ', 'W', 'P', ' ', 'W', ' ', ' ', ' ', 'P', 'W', ' ', ' ' },
  12. { ' ', ' ', 'W', ' ', ' ', 'W', ' ', 'T', ' ', ' ', 'W', ' ', ' ' },
  13. { ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'P', ' ', ' ', 'W', 'P', ' ' },
  14. { ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ' },
  15. { 'M', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ' },
  16. { ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ' },
  17. { ' ', ' ', ' ', ' ', ' ', ' ', 'P', ' ', ' ', ' ', ' ', ' ', ' ' } };
  18.  
  19.  
  20. }
  21. }
  22. /*
  23. maze[..]
  24. root = Node('A', 8)
  25. front = new List();
  26. front.push(root);
  27. while(!front.isEmpty()) {
  28. cur = front.pop();
  29. if (cur.isGoal()) {
  30. ...
  31. }
  32. children = cur.getChildren();
  33. front.push(children())
  34. sort(front);
  35. }
  36.  
  37.  
  38.  
  39. Class Node {
  40. char i;
  41. int j;
  42. children = null;
  43.  
  44. getChildren
  45. if children == null
  46. children = List()
  47. children.push
  48. return children
  49.  
  50. getValue
  51. return |i - goal.i| + |j-goal.i|
  52. }
  53. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement