bug resolutions
This commit is contained in:
parent
6de2a3ac93
commit
665498f98b
2 changed files with 28 additions and 10 deletions
|
@ -3,23 +3,42 @@
|
||||||
public class AppLaser {
|
public class AppLaser {
|
||||||
|
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
int start_i = 4;
|
int start_i = 3;
|
||||||
int start_j = 1;
|
int start_j = 1;
|
||||||
int start_dir = 12;
|
int start_dir = 12;
|
||||||
|
int firstState_i = 0;
|
||||||
|
int firstState_j = 0;
|
||||||
|
|
||||||
|
if (start_dir == 10) {
|
||||||
|
firstState_i = start_i - 1;
|
||||||
|
firstState_j = start_j;
|
||||||
|
}
|
||||||
|
else if (start_dir == 11) {
|
||||||
|
firstState_i = start_i + 1;
|
||||||
|
firstState_j = start_j;
|
||||||
|
}
|
||||||
|
else if (start_dir == 12) {
|
||||||
|
firstState_i = start_i;
|
||||||
|
firstState_j = start_j + 1;
|
||||||
|
}
|
||||||
|
else if (start_dir == 13) {
|
||||||
|
firstState_i = start_i;
|
||||||
|
firstState_j = start_j - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Stack <Situation> stack = new Stack <Situation>();
|
Stack <Situation> stack = new Stack <Situation>();
|
||||||
|
|
||||||
Universe universe = new Universe(6, 6, start_i, start_j, start_dir);
|
Universe universe = new Universe(5, 5, start_i, start_j, start_dir);
|
||||||
|
|
||||||
Situation previousState, currentState = new Situation(start_i, start_j, start_dir, 0);
|
Situation previousState, currentState = new Situation(firstState_i, firstState_j, start_dir, 0);
|
||||||
|
|
||||||
//universe.addObstacle(4, 4);
|
//universe.addObstacle(4, 4);
|
||||||
|
|
||||||
universe.print();
|
universe.print();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
while (!universe.isSolved()) {
|
||||||
do {
|
|
||||||
System.out.printf("%d %d %d %d %d", currentState.pos_i, currentState.pos_j, currentState.direction, currentState.nb_choix, universe.possibleChoices(currentState));
|
System.out.printf("%d %d %d %d %d", currentState.pos_i, currentState.pos_j, currentState.direction, currentState.nb_choix, universe.possibleChoices(currentState));
|
||||||
|
|
||||||
if (universe.canEvolve(currentState)) {
|
if (universe.canEvolve(currentState)) {
|
||||||
|
@ -33,9 +52,6 @@ public class AppLaser {
|
||||||
System.out.println("\n\n");
|
System.out.println("\n\n");
|
||||||
universe.print();
|
universe.print();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} while (!universe.isSolved());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class Universe {
|
||||||
this.grid = new int[height][length];
|
this.grid = new int[height][length];
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i = 1; i < this.height - 1; i++) {
|
for (i = 1; i < this.height - 1; i++) {
|
||||||
for (j = 1; j < this.length - 1; j++) {
|
for (j = 1; j < this.length - 1; j++) {
|
||||||
|
@ -104,7 +105,7 @@ public class Universe {
|
||||||
else return -1; // back
|
else return -1; // back
|
||||||
|
|
||||||
case 13: //west
|
case 13: //west
|
||||||
if (this.grid[i + 1][j] == 0) return 2; // left
|
if (this.grid[i + 1][j] == 0) return 2; // left
|
||||||
else if (this.grid[i - 1][j] == 0) return 3; // right
|
else if (this.grid[i - 1][j] == 0) return 3; // right
|
||||||
else return -1; // back
|
else return -1; // back
|
||||||
|
|
||||||
|
@ -190,6 +191,7 @@ public class Universe {
|
||||||
|
|
||||||
public void reset(Situation s) {
|
public void reset(Situation s) {
|
||||||
this.grid[s.pos_i][s.pos_j] = 0;
|
this.grid[s.pos_i][s.pos_j] = 0;
|
||||||
|
this.boxes_to_fill++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSolved() {
|
public boolean isSolved() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue