additions to previous commit

This commit is contained in:
Ninja-Jambon 2024-02-28 12:49:50 +01:00
parent ab7d525156
commit 6de2a3ac93
2 changed files with 31 additions and 12 deletions

View file

@ -5,6 +5,7 @@ public class Universe {
private int[][] grid;
private int length, height;
private int boxes_to_fill;
// Constructors
@ -30,6 +31,14 @@ public class Universe {
}
this.grid[i_start][j_start] = dir_start;
this.boxes_to_fill = 0;
for (i = 1; i < this.height - 1; i++) {
for (j = 1; j < this.length - 1; j++) {
if (this.grid[i][j] == 0) this.boxes_to_fill++;
}
}
}
// Methods
@ -41,10 +50,6 @@ public class Universe {
else {}
}
public boolean isSolved() {
return true;
}
public int possibleChoices(Situation s) {
int i = s.pos_i;
int j = s.pos_j;
@ -173,21 +178,27 @@ public class Universe {
j ++;
d = 12;
}
else if (c == 1 && d == 12 || c == 2 && d == 10 || c == 3 && d == 11) {
else if (c == 1 && d == 13 || c == 2 && d == 10 || c == 3 && d == 11) {
j --;
d = 13;
}
return new Situation(i, j, d, c);
this.boxes_to_fill++;
return new Situation(i, j, d, 0);
}
public void reset(int i, int j) {
this.grid[i][j] = -1;
public void reset(Situation s) {
this.grid[s.pos_i][s.pos_j] = 0;
}
public Situation restore(Situation current, Situation prev) {
public boolean isSolved() {
return this.boxes_to_fill == 0;
}
/*public Situation restore(Situation current, Situation prev) {
}
}*/
public void print() {
int i, j;