Search in sources :

Example 1 with BufferedQueue

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));
}
Also used : Alert(javafx.scene.control.Alert) Color(javafx.scene.paint.Color) Grid(bomb.modules.dh.hexamaze.hexalgorithm.storage.Grid) Label(javafx.scene.control.Label) Resettable(bomb.abstractions.Resettable) MazeComponent(bomb.components.hex.MazeComponent) GET_TOGGLE_NAME(bomb.tools.pattern.facade.FacadeFX.GET_TOGGLE_NAME) HexagonalPlane(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane) RED(javafx.scene.paint.Color.RED) HexNode(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexNode) Coordinates(bomb.tools.Coordinates) FXML(javafx.fxml.FXML) Quartet(org.javatuples.Quartet) ToggleGroup(javafx.scene.control.ToggleGroup) List(java.util.List) RadioButton(javafx.scene.control.RadioButton) Map(java.util.Map) DEFAULT_BACKGROUND_COLOR(bomb.components.hex.HexTile.DEFAULT_BACKGROUND_COLOR) HexTile(bomb.components.hex.HexTile) FacadeFX(bomb.tools.pattern.facade.FacadeFX) COLOR_MAP(bomb.modules.dh.hexamaze.Hexamaze.COLOR_MAP) BufferedQueue(bomb.tools.data.structures.queue.BufferedQueue) BufferedQueue(bomb.tools.data.structures.queue.BufferedQueue) HexTile(bomb.components.hex.HexTile) Color(javafx.scene.paint.Color) Map(java.util.Map)

Example 2 with BufferedQueue

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);
    }
}
Also used : BufferedQueue(bomb.tools.data.structures.queue.BufferedQueue) HexNode(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexNode)

Example 3 with BufferedQueue

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");
}
Also used : BufferedQueue(bomb.tools.data.structures.queue.BufferedQueue) HexNode(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexNode) Coordinates(bomb.tools.Coordinates)

Example 4 with BufferedQueue

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);
        }
    }
}
Also used : BufferedQueue(bomb.tools.data.structures.queue.BufferedQueue) HexNode(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexNode)

Example 5 with BufferedQueue

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();
}
Also used : BufferedQueue(bomb.tools.data.structures.queue.BufferedQueue) Grid(bomb.modules.dh.hexamaze.hexalgorithm.storage.Grid)

Aggregations

BufferedQueue (bomb.tools.data.structures.queue.BufferedQueue)5 HexNode (bomb.modules.dh.hexamaze.hexalgorithm.storage.HexNode)4 Grid (bomb.modules.dh.hexamaze.hexalgorithm.storage.Grid)2 Coordinates (bomb.tools.Coordinates)2 Resettable (bomb.abstractions.Resettable)1 HexTile (bomb.components.hex.HexTile)1 DEFAULT_BACKGROUND_COLOR (bomb.components.hex.HexTile.DEFAULT_BACKGROUND_COLOR)1 MazeComponent (bomb.components.hex.MazeComponent)1 COLOR_MAP (bomb.modules.dh.hexamaze.Hexamaze.COLOR_MAP)1 HexagonalPlane (bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane)1 FacadeFX (bomb.tools.pattern.facade.FacadeFX)1 GET_TOGGLE_NAME (bomb.tools.pattern.facade.FacadeFX.GET_TOGGLE_NAME)1 List (java.util.List)1 Map (java.util.Map)1 FXML (javafx.fxml.FXML)1 Alert (javafx.scene.control.Alert)1 Label (javafx.scene.control.Label)1 RadioButton (javafx.scene.control.RadioButton)1 ToggleGroup (javafx.scene.control.ToggleGroup)1 Color (javafx.scene.paint.Color)1