More cell

This commit is contained in:
Topher Lamey
2021-02-27 23:45:58 -07:00
parent d188128a7c
commit 5b2368fb9c

View File

@@ -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) {