Browse Source

RumbleBot markFiringLines

master
Your Average Code 11 months ago
parent
commit
8c40d7bacb
1 changed files with 45 additions and 3 deletions
  1. 45
    3
      src/RumbleBot.java

+ 45
- 3
src/RumbleBot.java View File

@@ -47,11 +47,52 @@ public class RumbleBot extends Bot {
for (int i = 0; i < data.length(); i++) {
grid[i % size][i / size] = data.charAt(i);
}
return markFiringLines(grid);
return grid;
}

protected char[][] markFiringLines(char[][] grid) {
return grid;
protected void markFiringLines(char[][] grid) {
int size = grid.length;
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {

if (grid[x][y] == 'v') {
int scanY = y;
while (scanY < size && !obstacles.contains("" + grid[x][y])) {
if (grid[x][scanY] == '.')
grid[x][scanY] = '*';
scanY++;
}
}

if (grid[x][y] == '^') {
int scanY = y;
while (scanY >= 0 && !obstacles.contains("" + grid[x][y])) {
if (grid[x][scanY] == '.')
grid[x][scanY] = '*';
scanY--;
}
}

if (grid[x][y] == '>') {
int scanX = x;
while (scanX < size && !obstacles.contains("" + grid[x][y])) {
if (grid[scanX][y] == '.')
grid[scanX][y] = '*';
scanX++;
}
}

if (grid[x][y] == '<') {
int scanX = x;
while (scanX >= 0 && !obstacles.contains("" + grid[x][y])) {
if (grid[scanX][y] == '.')
grid[scanX][y] = '*';
scanX--;
}
}

}
}
}

protected boolean isInLineOfSight(char[][] grid) {
@@ -91,6 +132,7 @@ public class RumbleBot extends Bot {
}

protected char breadthFirstSearch(char[][] grid) {
markFiringLines(grid);
int size = grid.length;
int start = size / 2;


Loading…
Cancel
Save