commit
This commit is contained in:
parent
2f51df0d82
commit
42746ad5b0
6 changed files with 353 additions and 9 deletions
Binary file not shown.
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 243 B |
Binary file not shown.
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 247 B |
187
saves/maze1.txt
Normal file
187
saves/maze1.txt
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
10
|
||||||
|
20
|
||||||
|
11
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
1
|
||||||
|
6
|
||||||
|
1
|
||||||
|
10
|
||||||
|
1
|
||||||
|
14
|
||||||
|
1
|
||||||
|
18
|
||||||
|
1
|
||||||
|
20
|
||||||
|
2
|
||||||
|
2
|
||||||
|
2
|
||||||
|
4
|
||||||
|
2
|
||||||
|
6
|
||||||
|
2
|
||||||
|
8
|
||||||
|
2
|
||||||
|
10
|
||||||
|
2
|
||||||
|
12
|
||||||
|
2
|
||||||
|
14
|
||||||
|
2
|
||||||
|
16
|
||||||
|
2
|
||||||
|
18
|
||||||
|
2
|
||||||
|
20
|
||||||
|
3
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
3
|
||||||
|
6
|
||||||
|
3
|
||||||
|
8
|
||||||
|
3
|
||||||
|
10
|
||||||
|
3
|
||||||
|
12
|
||||||
|
3
|
||||||
|
14
|
||||||
|
3
|
||||||
|
16
|
||||||
|
3
|
||||||
|
18
|
||||||
|
3
|
||||||
|
20
|
||||||
|
4
|
||||||
|
2
|
||||||
|
4
|
||||||
|
4
|
||||||
|
4
|
||||||
|
6
|
||||||
|
4
|
||||||
|
8
|
||||||
|
4
|
||||||
|
10
|
||||||
|
4
|
||||||
|
12
|
||||||
|
4
|
||||||
|
14
|
||||||
|
4
|
||||||
|
16
|
||||||
|
4
|
||||||
|
18
|
||||||
|
4
|
||||||
|
20
|
||||||
|
5
|
||||||
|
2
|
||||||
|
5
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
5
|
||||||
|
8
|
||||||
|
5
|
||||||
|
10
|
||||||
|
5
|
||||||
|
12
|
||||||
|
5
|
||||||
|
14
|
||||||
|
5
|
||||||
|
16
|
||||||
|
5
|
||||||
|
18
|
||||||
|
5
|
||||||
|
20
|
||||||
|
6
|
||||||
|
2
|
||||||
|
6
|
||||||
|
4
|
||||||
|
6
|
||||||
|
6
|
||||||
|
6
|
||||||
|
8
|
||||||
|
6
|
||||||
|
10
|
||||||
|
6
|
||||||
|
12
|
||||||
|
6
|
||||||
|
14
|
||||||
|
6
|
||||||
|
16
|
||||||
|
6
|
||||||
|
18
|
||||||
|
6
|
||||||
|
20
|
||||||
|
7
|
||||||
|
2
|
||||||
|
7
|
||||||
|
4
|
||||||
|
7
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
7
|
||||||
|
10
|
||||||
|
7
|
||||||
|
12
|
||||||
|
7
|
||||||
|
14
|
||||||
|
7
|
||||||
|
16
|
||||||
|
7
|
||||||
|
18
|
||||||
|
7
|
||||||
|
20
|
||||||
|
8
|
||||||
|
2
|
||||||
|
8
|
||||||
|
4
|
||||||
|
8
|
||||||
|
6
|
||||||
|
8
|
||||||
|
8
|
||||||
|
8
|
||||||
|
10
|
||||||
|
8
|
||||||
|
12
|
||||||
|
8
|
||||||
|
14
|
||||||
|
8
|
||||||
|
16
|
||||||
|
8
|
||||||
|
18
|
||||||
|
8
|
||||||
|
20
|
||||||
|
9
|
||||||
|
2
|
||||||
|
9
|
||||||
|
4
|
||||||
|
9
|
||||||
|
6
|
||||||
|
9
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
9
|
||||||
|
12
|
||||||
|
9
|
||||||
|
14
|
||||||
|
9
|
||||||
|
16
|
||||||
|
9
|
||||||
|
18
|
||||||
|
9
|
||||||
|
20
|
||||||
|
10
|
||||||
|
4
|
||||||
|
10
|
||||||
|
8
|
||||||
|
10
|
||||||
|
12
|
||||||
|
10
|
||||||
|
16
|
||||||
|
10
|
||||||
|
20
|
155
saves/maze2.txt
Normal file
155
saves/maze2.txt
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
10
|
||||||
|
20
|
||||||
|
11
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
1
|
||||||
|
6
|
||||||
|
1
|
||||||
|
10
|
||||||
|
1
|
||||||
|
14
|
||||||
|
1
|
||||||
|
18
|
||||||
|
1
|
||||||
|
20
|
||||||
|
2
|
||||||
|
2
|
||||||
|
2
|
||||||
|
4
|
||||||
|
2
|
||||||
|
6
|
||||||
|
2
|
||||||
|
7
|
||||||
|
2
|
||||||
|
8
|
||||||
|
2
|
||||||
|
10
|
||||||
|
2
|
||||||
|
12
|
||||||
|
2
|
||||||
|
13
|
||||||
|
2
|
||||||
|
14
|
||||||
|
2
|
||||||
|
15
|
||||||
|
2
|
||||||
|
16
|
||||||
|
2
|
||||||
|
18
|
||||||
|
2
|
||||||
|
20
|
||||||
|
3
|
||||||
|
4
|
||||||
|
3
|
||||||
|
18
|
||||||
|
4
|
||||||
|
2
|
||||||
|
4
|
||||||
|
4
|
||||||
|
4
|
||||||
|
5
|
||||||
|
4
|
||||||
|
6
|
||||||
|
4
|
||||||
|
8
|
||||||
|
4
|
||||||
|
9
|
||||||
|
4
|
||||||
|
10
|
||||||
|
4
|
||||||
|
12
|
||||||
|
4
|
||||||
|
14
|
||||||
|
4
|
||||||
|
16
|
||||||
|
4
|
||||||
|
18
|
||||||
|
4
|
||||||
|
19
|
||||||
|
4
|
||||||
|
20
|
||||||
|
5
|
||||||
|
12
|
||||||
|
5
|
||||||
|
14
|
||||||
|
6
|
||||||
|
2
|
||||||
|
6
|
||||||
|
4
|
||||||
|
6
|
||||||
|
6
|
||||||
|
6
|
||||||
|
7
|
||||||
|
6
|
||||||
|
8
|
||||||
|
6
|
||||||
|
10
|
||||||
|
6
|
||||||
|
11
|
||||||
|
6
|
||||||
|
12
|
||||||
|
6
|
||||||
|
14
|
||||||
|
6
|
||||||
|
15
|
||||||
|
6
|
||||||
|
16
|
||||||
|
6
|
||||||
|
18
|
||||||
|
6
|
||||||
|
19
|
||||||
|
6
|
||||||
|
20
|
||||||
|
7
|
||||||
|
1
|
||||||
|
7
|
||||||
|
2
|
||||||
|
8
|
||||||
|
2
|
||||||
|
8
|
||||||
|
4
|
||||||
|
8
|
||||||
|
6
|
||||||
|
8
|
||||||
|
8
|
||||||
|
8
|
||||||
|
10
|
||||||
|
8
|
||||||
|
11
|
||||||
|
8
|
||||||
|
12
|
||||||
|
8
|
||||||
|
13
|
||||||
|
8
|
||||||
|
14
|
||||||
|
8
|
||||||
|
16
|
||||||
|
8
|
||||||
|
17
|
||||||
|
8
|
||||||
|
18
|
||||||
|
8
|
||||||
|
20
|
||||||
|
9
|
||||||
|
4
|
||||||
|
9
|
||||||
|
12
|
||||||
|
9
|
||||||
|
16
|
||||||
|
9
|
||||||
|
18
|
||||||
|
10
|
||||||
|
3
|
||||||
|
10
|
||||||
|
4
|
||||||
|
10
|
||||||
|
8
|
||||||
|
10
|
||||||
|
12
|
||||||
|
10
|
||||||
|
16
|
||||||
|
10
|
||||||
|
20
|
|
@ -65,6 +65,8 @@ public class Grid extends JPanel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.universe.resetUniverse();
|
||||||
|
|
||||||
switch (this.universe.getGrid()[coord_i + 1][coord_j + 1]) {
|
switch (this.universe.getGrid()[coord_i + 1][coord_j + 1]) {
|
||||||
case 0:
|
case 0:
|
||||||
if (this.selected == 1) {
|
if (this.selected == 1) {
|
||||||
|
@ -203,6 +205,10 @@ public class Grid extends JPanel {
|
||||||
this.printUniverseGrid(this.universe.getGrid());
|
this.printUniverseGrid(this.universe.getGrid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void alert(String message) {
|
||||||
|
JOptionPane.showMessageDialog(this, message);
|
||||||
|
}
|
||||||
|
|
||||||
public void solve() {
|
public void solve() {
|
||||||
this.universe.resetUniverse();
|
this.universe.resetUniverse();
|
||||||
final Universe universe = this.universe;
|
final Universe universe = this.universe;
|
||||||
|
@ -230,7 +236,7 @@ public class Grid extends JPanel {
|
||||||
int best_filled_boxes = 0;
|
int best_filled_boxes = 0;
|
||||||
int best_nb_mirrors = 0;
|
int best_nb_mirrors = 0;
|
||||||
|
|
||||||
long lastPrinted = Instant.now().toEpochMilli();
|
long start = Instant.now().toEpochMilli();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (universe.canEvolve(currentState)) {
|
if (universe.canEvolve(currentState)) {
|
||||||
|
@ -241,12 +247,9 @@ public class Grid extends JPanel {
|
||||||
bestGrid = universe.copyGrid();
|
bestGrid = universe.copyGrid();
|
||||||
best_filled_boxes = universe.getFilledBoxes();
|
best_filled_boxes = universe.getFilledBoxes();
|
||||||
best_nb_mirrors = universe.getNbMirrors();
|
best_nb_mirrors = universe.getNbMirrors();
|
||||||
|
|
||||||
if (Instant.now().toEpochMilli() - lastPrinted > refreshRate) {
|
|
||||||
printUniverseGrid(bestGrid);
|
printUniverseGrid(bestGrid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (stack.size() > 0) {
|
else if (stack.size() > 0) {
|
||||||
currentState = stack.pop();
|
currentState = stack.pop();
|
||||||
universe.reset(currentState);
|
universe.reset(currentState);
|
||||||
|
@ -256,8 +259,8 @@ public class Grid extends JPanel {
|
||||||
} while (stack.size() != 0 && solving == true);
|
} while (stack.size() != 0 && solving == true);
|
||||||
|
|
||||||
solving = false;
|
solving = false;
|
||||||
Universe.print(bestGrid, width + 2, height + 2, 4, 4);
|
String message = "Solved in " + ((Instant.now().toEpochMilli() - start)/1000) + "s and " + ((Instant.now().toEpochMilli() - start)%1000) + "ms \nMirrors : " + best_nb_mirrors + "\nLaser length : " + best_filled_boxes;
|
||||||
printUniverseGrid(bestGrid);
|
alert(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
computeThread.start();
|
computeThread.start();
|
||||||
|
|
|
@ -109,8 +109,6 @@ public class Window extends JFrame {
|
||||||
toolsMenu.addSeparator();
|
toolsMenu.addSeparator();
|
||||||
toolsMenu.add(changeSize);
|
toolsMenu.add(changeSize);
|
||||||
toolsMenu.addSeparator();
|
toolsMenu.addSeparator();
|
||||||
toolsMenu.add(solve);
|
|
||||||
toolsMenu.addSeparator();
|
|
||||||
toolsMenu.add(reset);
|
toolsMenu.add(reset);
|
||||||
|
|
||||||
solveMenu.add(solve);
|
solveMenu.add(solve);
|
||||||
|
@ -167,6 +165,7 @@ public class Window extends JFrame {
|
||||||
|
|
||||||
this.universe.changeUniverseDim(universe_width + 2, universe_height + 2);
|
this.universe.changeUniverseDim(universe_width + 2, universe_height + 2);
|
||||||
this.universe.changeUniverseStart(start_i, start_j, start_dir);
|
this.universe.changeUniverseStart(start_i, start_j, start_dir);
|
||||||
|
this.universe.resetUniverseObstacles();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue