aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-25 22:27:22 +0900
committersyeyoung <cyong06@naver.com>2021-07-25 22:28:49 +0900
commit932399472cb653f5a8fdc1095fa941656a729650 (patch)
tree6049fdf96de7b2967c56d1d6ea62a6c473845c0a /src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder
parenta6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6 (diff)
downloadSkyblock-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/roomfinder')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java30
1 files changed, 22 insertions, 8 deletions
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;