-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
51 lines (31 loc) · 1.8 KB
/
Copy pathMain.java
File metadata and controls
51 lines (31 loc) · 1.8 KB
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
51
/**
* Created by Sonal baba on 4/1/2017.
*/
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
PathFindingOnSquaredGrid grid= new PathFindingOnSquaredGrid();
// The following will generate a 10x10 squared grid with relatively few obstacles in it
// The lower the second parameter, the more obstacles (black cells) are generated
boolean[][] randomlyGenMatrix = grid.random(10,0.6);
StdArrayIO.print(randomlyGenMatrix);
grid.show(randomlyGenMatrix, true);
// Reading the coordinates for points A and B on the input squared grid.
Scanner in = new Scanner(System.in);
System.out.println("\nENTER x1 FOR A >");
int Ay1 = in.nextInt();
System.out.println("ENTER y1 fOR A > ");
int Ax1 = in.nextInt();
System.out.println("ENTER x2 FOR B > ");
int By2 = in.nextInt();
System.out.println("ENTER y2 FOR B > ");
int Bx2 = in.nextInt();
Stopwatch time = new Stopwatch();
//ArrayList<PathFindingOnSquaredGrid.Node> path1 = new PathFindingOnSquaredGrid().distance(randomlyGenMatrix, Ax1, Ay1, Bx2, By2,grid.Manhattan(),"MANHATTAN",true);
//System.out.println(time.elapsedTime());
// ArrayList<PathFindingOnSquaredGrid.Node> path2 = new PathFindingOnSquaredGrid().distance(randomlyGenMatrix, Ax1, Ay1, Bx2, By2,grid.Euclidean(),"EUCLIDEAN",false);
ArrayList<PathFindingOnSquaredGrid.Node> path3 = new PathFindingOnSquaredGrid().distance(randomlyGenMatrix, Ax1, Ay1, Bx2, By2,grid.Chebyshev(),"CHEBYSHEV",false);
grid.show(randomlyGenMatrix, true, Ax1, Ay1, Bx2, By2, path3);
}
}