bug resolutions
This commit is contained in:
parent
665498f98b
commit
561069b074
3 changed files with 36 additions and 21 deletions
|
@ -5,7 +5,7 @@ public class AppLaser {
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
int start_i = 3;
|
int start_i = 3;
|
||||||
int start_j = 1;
|
int start_j = 1;
|
||||||
int start_dir = 12;
|
int start_dir = 10;
|
||||||
int firstState_i = 0;
|
int firstState_i = 0;
|
||||||
int firstState_j = 0;
|
int firstState_j = 0;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class AppLaser {
|
||||||
|
|
||||||
Stack <Situation> stack = new Stack <Situation>();
|
Stack <Situation> stack = new Stack <Situation>();
|
||||||
|
|
||||||
Universe universe = new Universe(5, 5, start_i, start_j, start_dir);
|
Universe universe = new Universe(8, 8, start_i, start_j, start_dir);
|
||||||
|
|
||||||
Situation previousState, currentState = new Situation(firstState_i, firstState_j, start_dir, 0);
|
Situation previousState, currentState = new Situation(firstState_i, firstState_j, start_dir, 0);
|
||||||
|
|
||||||
|
@ -39,19 +39,25 @@ public class AppLaser {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (!universe.isSolved()) {
|
while (!universe.isSolved()) {
|
||||||
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("i: %d, j: %d, dir: %d, choice: %d, possible: %d\n", currentState.pos_i, currentState.pos_j, currentState.direction, currentState.nb_choix, universe.possibleChoices(currentState));
|
||||||
|
|
||||||
if (universe.canEvolve(currentState)) {
|
if (universe.canEvolve(currentState)) {
|
||||||
stack.push(currentState.copy(universe.possibleChoices(currentState)));
|
stack.push(currentState.copy(universe.possibleChoices(currentState)));
|
||||||
currentState = universe.evolve(currentState);
|
currentState = universe.evolve(currentState);
|
||||||
}
|
}
|
||||||
else {
|
else if (stack.size() > 0) {
|
||||||
currentState = stack.pop();
|
currentState = stack.pop();
|
||||||
universe.reset(currentState);
|
universe.reset(currentState);
|
||||||
|
|
||||||
|
//System.out.println("\n\n");
|
||||||
|
//universe.print();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("\n\n");
|
System.out.println("\n\n");
|
||||||
|
|
||||||
universe.print();
|
universe.print();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,10 @@ public class Universe {
|
||||||
// adding the miror
|
// adding the miror
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 1:
|
||||||
|
this.grid[i][j] = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
this.grid[i][j] = 2;
|
this.grid[i][j] = 2;
|
||||||
break;
|
break;
|
||||||
|
@ -184,7 +188,7 @@ public class Universe {
|
||||||
d = 13;
|
d = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.boxes_to_fill++;
|
this.boxes_to_fill--;
|
||||||
|
|
||||||
return new Situation(i, j, d, 0);
|
return new Situation(i, j, d, 0);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +199,7 @@ public class Universe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSolved() {
|
public boolean isSolved() {
|
||||||
return this.boxes_to_fill == 0;
|
return this.boxes_to_fill - 1 == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public Situation restore(Situation current, Situation prev) {
|
/*public Situation restore(Situation current, Situation prev) {
|
||||||
|
@ -211,6 +215,10 @@ public class Universe {
|
||||||
System.out.printf(" X");
|
System.out.printf(" X");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
System.out.printf(" +");
|
||||||
|
break;
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
System.out.printf(" ^");
|
System.out.printf(" ^");
|
||||||
break;
|
break;
|
||||||
|
|
1
algo.txt
1
algo.txt
|
@ -28,6 +28,7 @@ Le truc avec la pile:
|
||||||
types de cases:
|
types de cases:
|
||||||
- 0 case vide
|
- 0 case vide
|
||||||
- -1 obstacle
|
- -1 obstacle
|
||||||
|
- 1 laser
|
||||||
- 2 miroir gauche
|
- 2 miroir gauche
|
||||||
- 3 miroir droite
|
- 3 miroir droite
|
||||||
- 10 départ nord
|
- 10 départ nord
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue