use of bomb.tools.data.structures.queue.BufferedQueue in project GradleCenturion by Ultraviolet-Ninja.
the class HexamazeController method fillHexTiles.
private static void fillHexTiles(List<HexTile> tileList, List<Coordinates> coordinatesList, int colorValue) {
Color color = RED;
for (Map.Entry<Color, Integer> entry : COLOR_MAP.entrySet()) {
if (entry.getValue() == colorValue)
color = entry.getKey();
}
for (HexTile hexTile : tileList) hexTile.setBackgroundFill(DEFAULT_BACKGROUND_COLOR);
BufferedQueue<BufferedQueue<HexTile>> tileQueues = HexagonalPlane.convertFromList(tileList);
Color finalColor = color;
coordinatesList.stream().map(c -> tileQueues.get(c.x()).get(c.y())).forEach(tile -> tile.setBackgroundFill(finalColor));
}
use of bomb.tools.data.structures.queue.BufferedQueue in project GradleCenturion by Ultraviolet-Ninja.
the class MazeSearch method moveToNextSegment.
private static void moveToNextSegment(BufferedQueue<BufferedQueue<HexNode>> pillar, HexagonalPlane copy) {
BufferedQueue<BufferedQueue<HexNode>> copiedQueues = copy.getBufferedQueues();
for (BufferedQueue<HexNode> column : copiedQueues) column.removeFirst();
int index = 0;
for (BufferedQueue<HexNode> column : pillar) {
HexNode nextNode = column.removeFirst();
copiedQueues.get(index++).add(nextNode);
}
}
use of bomb.tools.data.structures.queue.BufferedQueue in project GradleCenturion by Ultraviolet-Ninja.
the class MazeRunner method findStartingLocation.
private static Coordinates findStartingLocation(Grid grid) {
BufferedQueue<BufferedQueue<HexNode>> gridQueues = grid.getHexagon().getBufferedQueues();
int size = gridQueues.size();
for (int x = 0; x < size; x++) {
BufferedQueue<HexNode> column = gridQueues.get(x);
for (int y = 0; y < column.size(); y++) {
HexNode currentNode = column.get(y);
if (currentNode.getColor() != -1)
return new Coordinates(x, y);
}
}
throw new RuntimeException("Failed to find start position");
}
use of bomb.tools.data.structures.queue.BufferedQueue in project GradleCenturion by Ultraviolet-Ninja.
the class ExitCheckerTest method setPegLocations.
public static void setPegLocations(@NotNull Grid grid, Set<Integer> locations) {
BufferedQueue<BufferedQueue<HexNode>> gridQueues = grid.getHexagon().getBufferedQueues();
int locationCounter = 0;
for (BufferedQueue<HexNode> column : gridQueues) {
for (HexNode node : column) {
if (locations.contains(locationCounter++))
node.setColor(RED_PEG_VALUE);
}
}
}
use of bomb.tools.data.structures.queue.BufferedQueue in project GradleCenturion by Ultraviolet-Ninja.
the class MazeSearch method search.
public static Optional<Grid> search(@NotNull Maze maze, @NotNull Grid grid) {
int gridSpan = grid.getHexagon().getSpan();
int lastIndex = maze.getHexagon().getSpan() - gridSpan;
BufferedQueue<BufferedQueue<HexNode>> pillar;
Grid output;
for (int offset = -1; ++offset <= lastIndex; ) {
pillar = generatePillar(maze, gridSpan, offset);
output = searchPillar(pillar, grid);
if (output != null)
return Optional.of(output);
}
return Optional.empty();
}
Aggregations