improved display
This commit is contained in:
parent
8f4421bc12
commit
a5090c2bcf
2 changed files with 12 additions and 8 deletions
|
@ -8,8 +8,8 @@ public class AppLaser {
|
||||||
int start_i = 3;
|
int start_i = 3;
|
||||||
int start_j = 1;
|
int start_j = 1;
|
||||||
int start_dir = 11;
|
int start_dir = 11;
|
||||||
int universe_width = 6;
|
int universe_width = 21;
|
||||||
int universe_height = 6;
|
int universe_height = 20;
|
||||||
int firstState_i = start_i;
|
int firstState_i = start_i;
|
||||||
int firstState_j = start_j;
|
int firstState_j = start_j;
|
||||||
|
|
||||||
|
@ -31,7 +31,11 @@ public class AppLaser {
|
||||||
universe.addObstacle(2, 4);
|
universe.addObstacle(2, 4);
|
||||||
universe.addObstacle(3, 4);
|
universe.addObstacle(3, 4);
|
||||||
|
|
||||||
universe.print();
|
|
||||||
|
System.out.print("\033[H\033[2J");
|
||||||
|
System.out.flush();
|
||||||
|
|
||||||
|
universe.print(2, 4);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (!universe.isSolved()) {
|
while (!universe.isSolved()) {
|
||||||
|
@ -45,15 +49,14 @@ public class AppLaser {
|
||||||
currentState = stack.pop();
|
currentState = stack.pop();
|
||||||
universe.reset(currentState);
|
universe.reset(currentState);
|
||||||
|
|
||||||
//System.out.println("\n\n");
|
universe.print(universe_height + 6, 4);
|
||||||
//universe.print();
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
universe.print();
|
//universe.print(universe_height + 6, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("\n\n");
|
System.out.println("\n\n");
|
||||||
universe.print();
|
universe.print(universe_height + 6, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,10 +210,11 @@ public class Universe {
|
||||||
return this.boxes_to_fill == 0;
|
return this.boxes_to_fill == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print() {
|
public void print(int pos_i, int pos_j) {
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i = 0; i < this.height; i++) {
|
for (i = 0; i < this.height; i++) {
|
||||||
for (j = 0; j < this.width; j++) {
|
for (j = 0; j < this.width; j++) {
|
||||||
|
System.out.print("\033[" + (i + pos_i) + ";" + (j*2 + pos_j) + "H");
|
||||||
switch (this.grid[i][j]) {
|
switch (this.grid[i][j]) {
|
||||||
case -1:
|
case -1:
|
||||||
System.out.printf(" X");
|
System.out.printf(" X");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue