-
Notifications
You must be signed in to change notification settings - Fork 174
/
Copy pathAlgoVisualizer.java
50 lines (36 loc) · 1.16 KB
/
AlgoVisualizer.java
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
import java.awt.*;
import java.awt.event.*;
public class AlgoVisualizer {
private static int DELAY = 5;
private static int blockSide = 80;
private GameData data;
private AlgoFrame frame;
public AlgoVisualizer(String filename){
data = new GameData(filename);
int sceneWidth = data.M() * blockSide;
int sceneHeight = data.N() * blockSide;
EventQueue.invokeLater(() -> {
frame = new AlgoFrame("Move the Box Solver", sceneWidth,sceneHeight);
new Thread(() -> {
run();
}).start();
});
}
private void run(){
setData();
if(data.solve())
System.out.println("The game has a solution!");
else
System.out.println("The game does NOT have a solution.");
}
private void setData(){
frame.render(data);
AlgoVisHelper.pause(DELAY);
}
public static void main(String[] args) {
// String filename = "level/boston_09.txt";
// String filename = "level/boston_16.txt";
String filename = "level/test.txt";
AlgoVisualizer vis = new AlgoVisualizer(filename);
}
}