mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
More cell
This commit is contained in:
@@ -51,27 +51,26 @@ public class Amazing {
|
|||||||
int row = 0;
|
int row = 0;
|
||||||
int count = 2;
|
int count = 2;
|
||||||
|
|
||||||
Cell cell = grid.cells[row][col];
|
|
||||||
while (count != totalWalls) {
|
while (count != totalWalls) {
|
||||||
ArrayList<Direction> possibleDirs = getPossibleDirs(grid, new Cell(row, col));
|
Cell cell = grid.cells[row][col];
|
||||||
|
ArrayList<Direction> possibleDirs = getPossibleDirs(grid, cell);
|
||||||
|
|
||||||
if (possibleDirs.size() != 0) {
|
if (possibleDirs.size() != 0) {
|
||||||
Direction direction = possibleDirs.get(random(0, possibleDirs.size()));
|
Direction direction = possibleDirs.get(random(0, possibleDirs.size()));
|
||||||
if (direction == Direction.GO_LEFT) {
|
if (direction == Direction.GO_LEFT) {
|
||||||
col--;
|
cell = grid.cells[row][--col];
|
||||||
grid.cells[row][col].exitType = EXIT_RIGHT;
|
cell.exitType = EXIT_RIGHT;
|
||||||
} else if (direction == Direction.GO_UP) {
|
} else if (direction == Direction.GO_UP) {
|
||||||
row--;
|
cell = grid.cells[--row][col];
|
||||||
grid.cells[row][col].exitType = EXIT_DOWN;
|
cell.exitType = EXIT_DOWN;
|
||||||
} else if (direction == Direction.GO_RIGHT) {
|
} else if (direction == Direction.GO_RIGHT) {
|
||||||
grid.cells[row][col].exitType = grid.cells[row][col].exitType + EXIT_RIGHT;
|
cell.exitType = cell.exitType + EXIT_RIGHT;
|
||||||
col++;
|
cell = grid.cells[row][++col];
|
||||||
} else if (direction == Direction.GO_DOWN) {
|
} else if (direction == Direction.GO_DOWN) {
|
||||||
grid.cells[row][col].exitType = grid.cells[row][col].exitType + EXIT_DOWN;
|
cell.exitType = cell.exitType + EXIT_DOWN;
|
||||||
row++;
|
cell = grid.cells[++row][col];
|
||||||
}
|
}
|
||||||
grid.cells[row][col].count = count;
|
cell.count = count++;
|
||||||
count++;
|
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
if (col != grid.lastCol) {
|
if (col != grid.lastCol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user