Search in sources :

Example 1 with HexagonalPlane

use of bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane in project GradleCenturion by Ultraviolet-Ninja.

the class MazeSearch method searchPillar.

private static Grid searchPillar(BufferedQueue<BufferedQueue<HexNode>> pillar, Grid grid) {
    int gridSideLength = grid.getHexagon().getSideLength();
    trimPillar(pillar);
    HexagonalPlane copiedHexagon = new HexagonalPlane(createInitialCopy(pillar, gridSideLength), gridSideLength);
    HexagonalPlane originalGrid = grid.getHexagon();
    Grid output = compareFullRotation(originalGrid, copiedHexagon);
    while (output == null && isNotColumnEmpty(pillar)) {
        moveToNextSegment(pillar, copiedHexagon);
        output = compareFullRotation(originalGrid, copiedHexagon);
    }
    return output;
}
Also used : Grid(bomb.modules.dh.hexamaze.hexalgorithm.storage.Grid) HexagonalPlane(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane)

Example 2 with HexagonalPlane

use of bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane in project GradleCenturion by Ultraviolet-Ninja.

the class Hexamaze method solve.

@NotNull
public static Quartet<@NotNull Grid, @Nullable String, @Nullable Integer, @Nullable List<Coordinates>> solve(@NotNull List<HexNode> nodeList) throws IllegalArgumentException, IllegalStateException {
    Maze maze = new Maze();
    Grid original = new Grid(new HexagonalPlane(nodeList));
    Grid found = MazeSearch.search(maze, original).orElseThrow(() -> {
        throw new IllegalArgumentException("Could not find maze from given shapes");
    });
    int colorValue = copyPegLocation(original, found);
    Optional<Pair<String, List<Coordinates>>> exitInfoOptional = ExitChecker.findPossibleExits(found);
    if (exitInfoOptional.isEmpty())
        return new Quartet<>(found, null, null, null);
    Pair<String, List<Coordinates>> exitInfo = exitInfoOptional.get();
    return new Quartet<>(found, exitInfo.getValue0(), colorValue, MazeRunner.runMaze(found, exitInfo.getValue1()));
}
Also used : Quartet(org.javatuples.Quartet) Grid(bomb.modules.dh.hexamaze.hexalgorithm.storage.Grid) Coordinates(bomb.tools.Coordinates) HexagonalPlane(bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane) List(java.util.List) Maze(bomb.modules.dh.hexamaze.hexalgorithm.storage.Maze) Pair(org.javatuples.Pair) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Grid (bomb.modules.dh.hexamaze.hexalgorithm.storage.Grid)2 HexagonalPlane (bomb.modules.dh.hexamaze.hexalgorithm.storage.HexagonalPlane)2 Maze (bomb.modules.dh.hexamaze.hexalgorithm.storage.Maze)1 Coordinates (bomb.tools.Coordinates)1 List (java.util.List)1 Pair (org.javatuples.Pair)1 Quartet (org.javatuples.Quartet)1 NotNull (org.jetbrains.annotations.NotNull)1