Difference between revisions of "Thread:Talk:Main Page/Running Error - Robot is not stopping, forcing a stop"
Jump to navigation
Jump to search
Lavenderwong (talk | contribs) m (New thread: Running Error - Robot is not stopping, forcing a stop) |
m (fix syntax highlighting so I can read it) |
||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
Thank you. | Thank you. | ||
+ | |||
***** BATTLE 1, ROUND 1 ***** | ***** BATTLE 1, ROUND 1 ***** | ||
+ | |||
TURN 1: StudentRobot* (1) hard deadline exceeded - 532809us | TURN 1: StudentRobot* (1) hard deadline exceeded - 532809us | ||
+ | |||
Err> Robot StudentRobot* (1) is not stopping. Forcing a stop. | Err> Robot StudentRobot* (1) is not stopping. Forcing a stop. | ||
+ | |||
Err> Robot StudentRobot* (2) is not stopping. Forcing a stop. | Err> Robot StudentRobot* (2) is not stopping. Forcing a stop. | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Average computation time per turn: 511706 | Average computation time per turn: 511706 | ||
+ | |||
Max turn computation time: 532809 | Max turn computation time: 532809 | ||
− | |||
− | |||
− | + | <syntaxhighlight> | |
− | + | private boolean pathFinding_BFS(Node start, Node end){ | |
− | private boolean pathFinding_BFS(Node start, Node end){ | ||
LinkedList<Node> queue = new LinkedList<Node>(); | LinkedList<Node> queue = new LinkedList<Node>(); | ||
queue.add(start); | queue.add(start); | ||
Line 33: | Line 30: | ||
}else{ | }else{ | ||
for (Node n : temp.getAdjacentNode()){ | for (Node n : temp.getAdjacentNode()){ | ||
− | System.out.println("in node:" + n.getPointInPath().getX() + " y " + n.getPointInPath().getY()); | + | System.out.println("in node:" + n.getPointInPath().getX() + " y " + |
+ | n.getPointInPath().getY()); | ||
if (!n.isMarked()){ | if (!n.isMarked()){ | ||
n.setMarked(); | n.setMarked(); | ||
Line 42: | Line 40: | ||
} | } | ||
} | } | ||
− | |||
} | } | ||
return false; | return false; | ||
} | } | ||
+ | |||
public List<Point> getShortestPath(Point start){ | public List<Point> getShortestPath(Point start){ | ||
Node src = new Node(start); | Node src = new Node(start); | ||
Line 60: | Line 58: | ||
return path; | return path; | ||
} | } | ||
− | |||
} | } | ||
return path; | return path; | ||
} | } | ||
+ | </syntaxhighlight> |
Latest revision as of 17:43, 7 December 2013
When I start the battlefield,my robot and other enemy are frozen. The println messages are not displayed in the robot console. But the command prompt shows the following error. I check that the cause of error is the addition of node in my queue (queue.add(n)). However, this line of code shall be fine i guess. So I would like to ask how to solve this error message? (this part of my program is for path finding using bfs)
Thank you.
- BATTLE 1, ROUND 1 *****
TURN 1: StudentRobot* (1) hard deadline exceeded - 532809us
Err> Robot StudentRobot* (1) is not stopping. Forcing a stop.
Err> Robot StudentRobot* (2) is not stopping. Forcing a stop.
Average computation time per turn: 511706
Max turn computation time: 532809
private boolean pathFinding_BFS(Node start, Node end){
LinkedList<Node> queue = new LinkedList<Node>();
queue.add(start);
start.setMarked();
while (!queue.isEmpty()){
Node temp = (Node)queue.poll();
System.out.println("first node:" + temp.getPointInPath().getX() + " y " + temp.getPointInPath().getY());
if (temp.equals(end)){
temp.setPrevNodeInPath(temp.getPrevNodeInPath());
return true;
}else{
for (Node n : temp.getAdjacentNode()){
System.out.println("in node:" + n.getPointInPath().getX() + " y " +
n.getPointInPath().getY());
if (!n.isMarked()){
n.setMarked();
n.setPrevNodeInPath(temp);
System.out.println("test n");
queue.add(n); //problem here
}
}
}
}
return false;
}
public List<Point> getShortestPath(Point start){
Node src = new Node(start);
List<Point> path = new ArrayList<Point>();
for (int i=0;i<endup.size();i++){
Node destination = new Node(endup.get(i));
if (pathFinding_BFS(src, destination)){
while (destination.getPrevNodeInPath() != null){
destination = destination.getPrevNodeInPath();
path.add(destination.getPointInPath());
}
Collections.reverse(path);
return path;
}
}
return path;
}