diff options
author | syeyoung <cyong06@naver.com> | 2021-07-25 22:27:22 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-25 22:28:49 +0900 |
commit | 932399472cb653f5a8fdc1095fa941656a729650 (patch) | |
tree | 6049fdf96de7b2967c56d1d6ea62a6c473845c0a /src/main/java/kr/syeyoung/dungeonsguide/dungeon | |
parent | a6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6 (diff) | |
download | Skyblock-Dungeons-Guide-932399472cb653f5a8fdc1095fa941656a729650.tar.gz Skyblock-Dungeons-Guide-932399472cb653f5a8fdc1095fa941656a729650.tar.bz2 Skyblock-Dungeons-Guide-932399472cb653f5a8fdc1095fa941656a729650.zip |
Creating Fake Dungeons.
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
3 files changed, 26 insertions, 12 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index a86a5326..3bea78f8 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -60,11 +60,11 @@ public class MapProcessor { @Getter private final BiMap<String, String> mapIconToPlayerMap = HashBiMap.create(); - @Getter + @Getter @Setter private Dimension unitRoomDimension; - @Getter + @Getter @Setter private Dimension doorDimension; // width: width of door, height: gap between rooms - @Getter + @Getter @Setter private Point topLeftMapPoint; @Setter diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java index a92d7a03..6ee6f9ee 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.regex.Pattern; public class DungeonSpecificDataProviderRegistry { - private static final Map<Pattern, DungeonSpecificDataProvider> doorFinders = new HashMap<Pattern, DungeonSpecificDataProvider>(); + public static final Map<Pattern, DungeonSpecificDataProvider> doorFinders = new HashMap<Pattern, DungeonSpecificDataProvider>(); static { doorFinders.put(Pattern.compile("The Catacombs (?:F[0-9]|E0)"), new CatacombDataProvider()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java index d7bc1c64..9c20bdf9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java @@ -67,24 +67,36 @@ public class RoomMatcher { shape = ShortUtils.topLeftifyInt(shape); List<DungeonRoomInfo> roomInfoList = DungeonRoomInfoRegistry.getByShape(shape); + int lowestcost = Integer.MAX_VALUE; + DungeonRoomInfo bestMatch = null; for (DungeonRoomInfo roomInfo : roomInfoList) { - if (tryMatching(roomInfo, rotation)) { - match = roomInfo; - this.rotation = rotation; - return match; + int cost = tryMatching(roomInfo, rotation); +// if () { +// match = roomInfo; +// this.rotation = rotation; +// return match; +// } + if (cost < lowestcost) { + lowestcost = cost; + bestMatch = roomInfo; + if (cost == 0) break; } } + match = bestMatch; + this.rotation = rotation; + return bestMatch; } return null; } - private boolean tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) { - if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return false; + private int tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) { + if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return Integer.MAX_VALUE; int[][] res = dungeonRoomInfo.getBlocks(); for (int i = 0; i < rotation; i++) res = ArrayUtils.rotateCounterClockwise(res); + int wrongs = 0; for (int z = 0; z < res.length; z ++) { for (int x = 0; x < res[0].length; x++) { int data = res[z][x]; @@ -92,11 +104,13 @@ public class RoomMatcher { Block b = dungeonRoom.getRelativeBlockAt(x,0,z); if (b == null || Block.getIdFromBlock(b) != data) { - return false; + wrongs++; + + if (wrongs > 10) return wrongs; } } } - return true; + return wrongs; } private static final int offset = 3; |