-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMove.java
More file actions
50 lines (44 loc) · 896 Bytes
/
Copy pathMove.java
File metadata and controls
50 lines (44 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package bfs;
public class Move extends Algo {
private int ants;
private int errors;
public Move(Vertex start, String end, int num_ants, int errors) {
super(start, end);
this.errors = errors;
this.ants = num_ants;
}
private int move_ant(int ant, int b) {
int print = b - ant;
if ((b >= ant - 1))
{
for (String x : getPath()) {
if (print <= 0)
break ;
if (print == 1) {
System.out.print("L" + (ant + 1) +"-" + x + " ");
if ((ant + 1 == ants) && x.equals(end))
return 1;
}
print--;
}
}
return 0;
}
public void print_path() {
int f = 1;
int done = 0;
bfs_search();
System.out.println();
if (!getPath().isEmpty() && errors == 0) {
while (done != 1) {
int i = -1;
while (++i < ants)
done = move_ant(i, f);
System.out.println();
f++;
}
}
else
System.out.println("Error");
}
}