Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Astar {
- static final int MONSTER = 4;
- static final int PUDDLE = 3;
- static final int TARGET = 2;
- static final int WALL = 1;
- public static void main(String[] args) {
- char[][] maze = {
- { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
- { ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ' },
- { ' ', ' ', 'W', 'P', ' ', 'W', ' ', ' ', ' ', 'P', 'W', ' ', ' ' },
- { ' ', ' ', 'W', ' ', ' ', 'W', ' ', 'T', ' ', ' ', 'W', ' ', ' ' },
- { ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'P', ' ', ' ', 'W', 'P', ' ' },
- { ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ' },
- { 'M', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ' },
- { ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ' },
- { ' ', ' ', ' ', ' ', ' ', ' ', 'P', ' ', ' ', ' ', ' ', ' ', ' ' } };
- }
- }
- /*
- maze[..]
- root = Node('A', 8)
- front = new List();
- front.push(root);
- while(!front.isEmpty()) {
- cur = front.pop();
- if (cur.isGoal()) {
- ...
- }
- children = cur.getChildren();
- front.push(children())
- sort(front);
- }
- Class Node {
- char i;
- int j;
- children = null;
- getChildren
- if children == null
- children = List()
- children.push
- return children
- getValue
- return |i - goal.i| + |j-goal.i|
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement