aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-21 21:22:44 +0900
committersyeyoung <cyong06@naver.com>2021-02-21 21:23:33 +0900
commit19e32413deb3dfc722ae66b861a76c43af6d0829 (patch)
tree1fa79ae4eb33d583793287d23e42d34ca4388e31 /src/main
parentf6b14be048af6d1e05d55de5895499136394948a (diff)
downloadSkyblock-Dungeons-Guide-19e32413deb3dfc722ae66b861a76c43af6d0829.tar.gz
Skyblock-Dungeons-Guide-19e32413deb3dfc722ae66b861a76c43af6d0829.tar.bz2
Skyblock-Dungeons-Guide-19e32413deb3dfc722ae66b861a76c43af6d0829.zip
new water puzzle solver
Diffstat (limited to 'src/main')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterCondition.java)6
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterConditionContradict.java)4
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java17
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java33
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java293
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java4
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java4
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java6
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java6
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java4
11 files changed, 225 insertions, 154 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterCondition.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java
index 26678af3..c1454806 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterCondition.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java
@@ -5,11 +5,11 @@ import lombok.Data;
@Data
@AllArgsConstructor
-public class WaterCondition {
+public class LeverState {
private String blockId;
private boolean requiredState;
- public WaterCondition invert() {
- return new WaterCondition(blockId, !requiredState);
+ public LeverState invert() {
+ return new LeverState(blockId, !requiredState);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterConditionContradict.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java
index 64339655..f21008cf 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterConditionContradict.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java
@@ -1,7 +1,7 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle;
-public class WaterConditionContradict extends WaterCondition {
- public WaterConditionContradict() {
+public class LeverStateContradict extends LeverState {
+ public LeverStateContradict() {
super("contradict", true);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java
index ab19c562..23069f74 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java
@@ -1,6 +1,5 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle;
-import kr.syeyoung.dungeonsguide.config.Config;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
@@ -11,6 +10,7 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.util.BlockPos;
import java.awt.*;
+import java.util.List;
public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor {
@@ -70,21 +70,28 @@ public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor {
Route route = waterBoard.getCurrentRoute();
if (route != null) {
- for (WaterCondition condition : route.getConditionList()) {
+ int j = 1;
+ for (int i = 0; i < route.getConditionList().size(); i++) {
+ LeverState condition = route.getConditionList().get(i);
if (condition == null) continue;
SwitchData switchData = waterBoard.getValidSwitches().get(condition.getBlockId());
if (switchData.getCurrentState(getDungeonRoom().getContext().getWorld()) != condition.isRequiredState()) {
+
RenderUtils.highlightBlock(switchData.getSwitchLoc(), new Color(0,255,0,50), partialTicks, true);
+ RenderUtils.drawTextAtWorld("#"+j,switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY()+1, switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks);
RenderUtils.drawTextAtWorld(condition.isRequiredState() ? "on":"off",switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY(), switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks);
+ j++;
}
}
for (WaterNode node : route.getNodes()) {
RenderUtils.highlightBlock(node.getBlockPos(), new Color(0,255,255,50), partialTicks, true);
}
}
- BlockPos target = waterBoard.getTarget();
- if (target != null) {
- RenderUtils.highlightBlock(target, new Color(0,255,255,100), partialTicks, true);
+ List<BlockPos> targets = waterBoard.getTarget();
+ if (targets != null) {
+ for (BlockPos target : targets) {
+ RenderUtils.highlightBlock(target, new Color(0,255,255,100), partialTicks, true);
+ }
RenderUtils.highlightBlock(waterBoard.getToggleableMap().get("mainStream").getBlockPos(), new Color(0,255,0,255), partialTicks, true);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java
index cdff0477..a873d654 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java
@@ -1,25 +1,42 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle;
+import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.WaterNodeEnd;
import lombok.Data;
+import org.jetbrains.annotations.NotNull;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
+import java.util.*;
@Data
-public class Route implements Cloneable {
+public class Route implements Cloneable, Comparable {
private Set<WaterNode> nodes = new LinkedHashSet<WaterNode>();
- private Set<WaterCondition> conditionList = new HashSet<WaterCondition>();
- private int x, y;
+ private List<LeverState> conditionList = new ArrayList<LeverState>();
+ private Set<WaterNodeEnd> endingNodes = new HashSet<WaterNodeEnd>();
+ private int matches = 0;
+ private int stateFlops = 0;
+ private int notMatches = 0;
+
+ public double calculateCost() {
+ return (1.0/matches) * 50 + stateFlops * 10 + notMatches * 100;
+ }
+
@Override
protected Route clone() {
Route r = new Route();
r.getNodes().addAll(nodes);
r.getConditionList().addAll(conditionList);
- r.x = x;
- r.y = y;
+ r.getEndingNodes().addAll(endingNodes);
return r;
}
+
+ @Override
+ public int compareTo(@NotNull Object o) {
+ if (o instanceof Route) {
+ double var0 = calculateCost();
+ double var1 = ((Route)o).calculateCost();
+ return Double.compare(var0, var1);
+ }
+ return 0;
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java
index 009212a1..29a9a5dc 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java
@@ -1,6 +1,5 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle;
-import com.google.common.collect.Sets;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.*;
@@ -11,10 +10,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
-import org.lwjgl.Sys;
-import javax.vecmath.Vector2d;
-import java.awt.*;
import java.util.*;
import java.util.List;
@@ -42,13 +38,12 @@ public class WaterBoard {
@Getter
private Set<String> reqOpen = new HashSet<String>();
-
@Getter
private Route currentRoute;
@Getter
- private BlockPos target;
+ private List<BlockPos> target;
@Getter
- private String target2;
+ private List<String> target2;
public WaterBoard(RoomProcessorWaterPuzzle roomProcessorWaterPuzzle, OffsetPointSet frontPlate, OffsetPointSet backPlate, OffsetPointSet levers, OffsetPointSet doors, OffsetPoint leverMain) {
this.waterPuzzle = roomProcessorWaterPuzzle;
@@ -92,128 +87,196 @@ public class WaterBoard {
doorsToOpen.add(Block.getIdFromBlock(b)+":"+offsetPoint.getData(waterPuzzle.getDungeonRoom()));
}
}
- if (!(reqOpen.containsAll(doorsToOpen) && doorsToOpen.containsAll(reqOpen))) {
+// if (!(reqOpen.containsAll(doorsToOpen) && doorsToOpen.containsAll(reqOpen))) {
reqOpen = doorsToOpen;
if (doorsToOpen.size() != 0) {
- WaterNodeEnd end = waterNodeEndMap.get(doorsToOpen.iterator().next());
- target = end.getBlockPos();
- target2 = end.getResultId();
- currentRoute = pathFind(end);
+ Set<WaterNodeEnd> ends = new HashSet<WaterNodeEnd>();
+ for (String s : doorsToOpen) {
+ ends.add(waterNodeEndMap.get(s));
+ }
+ currentRoute = getBestRoute(ends);
+ target = new ArrayList<BlockPos>();
+ target2 = new ArrayList<String>();
+ if (currentRoute != null) {
+ for (WaterNodeEnd endingNode : currentRoute.getEndingNodes()) {
+ target.add(endingNode.getBlockPos());
+ target2.add(endingNode.getResultId());
+ }
+ }
}
- }
+// }
}
- private final Set<Point> possibleDir = Sets.newHashSet(new Point(0,-1), new Point(1,0), new Point(-1, 0));
- public Route pathFind(WaterNodeEnd endNode) {
-
- Route start = new Route();
- start.setX(endNode.getX());
- start.setY(endNode.getY());
- start.getNodes().add(endNode);
- Queue<Route> routes = new LinkedList<Route>();
- routes.add(start);
- List<Route> reachedStart = new ArrayList<Route>();
- while (!routes.isEmpty()) {
- Route r2 = routes.poll();
- int x = r2.getX();
- int y = r2.getY();
- for (Point vec:possibleDir) {
- WaterNode node = getNodeAt(x + vec.x, y + vec.y);
-
- if (node == null) continue;
- if (r2.getNodes().contains(node)) continue;
- if (!node.canWaterGoThrough()) continue;
-
- Route r = r2.clone();
- r.getNodes().add(node);
- r.getConditionList().add(node.getCondition());
- r.setX(x + vec.x);
- r.setY(y + vec.y);
-
- WaterNode void2 = getNodeAt(r.getX(), r.getY() + 1);
- if ((void2 == null || (void2.canWaterGoThrough() && void2.getCondition() == null)) && !r.getNodes().contains(void2)) {
- continue;
- }
+ public Route getBestRoute(Set<WaterNodeEnd> potentialEnds) {
+ int totalStates = (int) Math.pow(2, validSwitches.size() - 1);
+ List<SwitchData> switchData = new ArrayList<SwitchData>();
+ Set<LeverState> currentState = new HashSet<LeverState>();
+ World w = waterPuzzle.getDungeonRoom().getContext().getWorld();
+ for (SwitchData switchDatum : this.switchData) {
+ if (!switchDatum.getBlockId().equals("mainStream")) {
+ switchData.add(switchDatum);
+ }
+ currentState.add(new LeverState(switchDatum.getBlockId(), switchDatum.getCurrentState(w)));
+ }
+ PriorityQueue<Route> routes = new PriorityQueue<Route>();
- if (checkContradiction(r.getConditionList())) {
- continue;
- }
+ for (int i = 0; i < totalStates; i++) {
+ Set<LeverState> states = new HashSet<LeverState>();
+ for (int i1 = 0; i1 < switchData.size(); i1++) {
+ states.add(new LeverState(switchData.get(i1).getBlockId(), ((i >> i1) & 0x1) > 0));
+ }
+ states.add(new LeverState("mainStream", true));
- if (node instanceof WaterNodeStart) {
- reachedStart.add(r);
+ Route r = simulate(states);
+
+ for (LeverState leverState : currentState) {
+ if (!states.contains(leverState))
+ r.setStateFlops(r.getMatches() + 1);
+ }
+ for (WaterNodeEnd potentialEnd : potentialEnds) {
+ if (r.getEndingNodes().contains(potentialEnd)) {
+ r.setMatches(r.getMatches() + 1);
} else {
- routes.add(r);
+ r.setNotMatches(r.getNotMatches() + 1);
}
}
+ if (r.getMatches() > 0)
+ routes.add(r);
}
- Iterator<Route> routeIter = reachedStart.iterator();
- while (routeIter.hasNext()) {
- Route route = routeIter.next();
- addRouteConditions(route);
- if (checkContradiction(route.getConditionList()))
- routeIter.remove();
- }
- return reachedStart.get(0);
+ return routes.peek();
}
- public void addRouteConditions(Route r) {
- int prevY = 0;
- int startX = -1;
- for (WaterNode node : r.getNodes()) {
- int currY = node.getY();
- if (currY != prevY) {
- if (startX != -1) {
- int offset = node.getX() - startX;
- if (offset != 0) {
- int start = startX + (offset > 0 ? 1 : -1);
- int end = node.getX() + offset;
- int y = node.getY() + 2;
- int y2 = node.getY() + 1;
-
- boolean visited_offsetPt = false;
- for (int x = start; (start < end) ? (x <= end) : (x >= end); x += (start < end) ?1:-1){
- WaterNode node2 = getNodeAt(x, y2);
-
- if (node2 == null || !node2.canWaterGoThrough()) break;
-
- if (node2.canWaterGoThrough() && node2.getCondition() != null) {
- WaterCondition condition = node2.getCondition().invert();
- if (visited_offsetPt) {
- boolean isConditionContradicting = false;
- for (WaterCondition wc : r.getConditionList()) {
- if (wc ==null) continue;
- if (!wc.getBlockId().equals(condition.getBlockId())) continue;
- if (wc.isRequiredState() == condition.isRequiredState()) continue;
- isConditionContradicting = true;
- break;
- }
- if (!isConditionContradicting) {
- r.getConditionList().add(condition);
- break;
- }
- }
- }
- node2 = getNodeAt(x, y);
- if ((node2.canWaterGoThrough() && node2.getCondition() == null)) {
- r.getConditionList().add(new WaterConditionContradict());
- return;
- } else {
- if (node2.getCondition() != null) {
- r.getConditionList().add(node2.getCondition().invert());
- }
- }
- if (x == node.getX()) visited_offsetPt = true;
+ public Route simulate(Set<LeverState> leverStates) {
+ leverStates.add(null);
+ Route r = new Route();
+ Queue<WaterNode> toGoDownTo = new LinkedList<WaterNode>();
+ Set<WaterNode> searched = new HashSet<WaterNode>();
+ Set<LeverState> waterBlockingStates = new HashSet<LeverState>();
+ World w = waterPuzzle.getDungeonRoom().getContext().getWorld();
+ toGoDownTo.add(getNodeAt(waterNodeStart.getX(), waterNodeStart.getY() + 1));
+ while (!toGoDownTo.isEmpty()) {
+ WaterNode asd = toGoDownTo.poll();
+ if (asd == null) continue;
+ if (searched.contains(asd)) continue;
+ searched.add(asd);
+
+ if (asd instanceof WaterNodeEnd) {
+ if (!asd.isWaterFilled(w))
+ r.getEndingNodes().add((WaterNodeEnd) asd);
+ continue;
+ }
+
+ r.getNodes().add(asd);
+
+ if (asd.isWaterFilled(w) && (
+ (getNodeAt(asd.getX() + 1, asd.getY()) != null && getNodeAt(asd.getX() + 1, asd.getY()).isWaterFilled(w))
+ || (getNodeAt(asd.getX() - 1, asd.getY()) != null && getNodeAt(asd.getX() - 1, asd.getY()).isWaterFilled(w)))) {
+ boolean followWater = getNodeAt(asd.getX() - 1, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() - 1, asd.getY()).getCondition())
+ && getNodeAt(asd.getX() - 2, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() - 2, asd.getY()).getCondition());
+ for (int i = asd.getX(); i < asd.getX() + 8; i++) {
+ WaterNode nodehere = getNodeAt(i, asd.getY());
+ if (nodehere == null) break;
+ if (followWater && !nodehere.isWaterFilled(w)) break;
+ if (!nodehere.canWaterGoThrough()) break;
+ if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break;
+ if (!leverStates.contains(nodehere.getCondition()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition());
+ WaterNode down = getNodeAt(i, asd.getY() + 1);
+ if (i != asd.getX())
+ followWater = nodehere.isWaterFilled(w) && (down == null || (down.canWaterGoThrough() && leverStates.contains(down.getCondition())));
+ r.getNodes().add(nodehere);
+ if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) {
+ toGoDownTo.add(down);
+ }
+ }
+ followWater = getNodeAt(asd.getX() +1, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() + 1, asd.getY()).getCondition())
+ && getNodeAt(asd.getX() +2, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() + 2, asd.getY()).getCondition());
+ for (int i = asd.getX(); i > asd.getX() - 8; i--) {
+ WaterNode nodehere = getNodeAt(i, asd.getY());
+ if (nodehere == null) break;
+ if (followWater && !nodehere.isWaterFilled(w)) break;
+ if (!nodehere.canWaterGoThrough()) break;
+ if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break;
+ if (!leverStates.contains(nodehere.getCondition()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition());
+ WaterNode down = getNodeAt(i, asd.getY() + 1);
+ if (i != asd.getX())
+ followWater = nodehere.isWaterFilled(w) && (down == null || (down.canWaterGoThrough() && leverStates.contains(down.getCondition())));
+ r.getNodes().add(nodehere);
+ if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) {
+ toGoDownTo.add(down);
+ }
+ }
+ } else {
+ int minDistToDropRight = 9999;
+ for (int i = asd.getX(); i < asd.getX() + 8; i++) {
+ WaterNode nodehere = getNodeAt(i, asd.getY());;
+ if (nodehere == null) break;
+ if (!nodehere.canWaterGoThrough()) break;
+ if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break;
+ WaterNode down = getNodeAt(i, asd.getY() + 1);
+ if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) {
+ int dist = i - asd.getX();
+ if (dist < minDistToDropRight)
+ minDistToDropRight = dist;
+ break;
+ }
+ }
+ int minDistToDropLeft = 9999;
+ for (int i = asd.getX(); i > asd.getX() - 8; i--) {
+ WaterNode nodehere = getNodeAt(i, asd.getY());
+ if (nodehere == null) break;
+ if (!nodehere.canWaterGoThrough()) break;
+ if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break;
+ WaterNode down = getNodeAt(i, asd.getY() + 1);
+ if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) {
+ int dist = asd.getX() - i;
+ if (dist < minDistToDropLeft)
+ minDistToDropLeft = dist;
+ break;
+ }
+ }
+
+ int min = Math.min(minDistToDropRight, minDistToDropLeft);
+ if (min == 9999) continue;
+ if (minDistToDropRight == min) {
+ for (int i = asd.getX(); i <= asd.getX() + minDistToDropRight; i++) {
+ WaterNode nodehere = getNodeAt(i, asd.getY());
+ if (leverStates.contains(nodehere.getCondition()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition());
+ r.getNodes().add(nodehere);
+ WaterNode down = getNodeAt(i, asd.getY() + 1);
+ if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) {
+ toGoDownTo.add(down);
+ }
+ }
+ }
+ if (minDistToDropLeft == min) {
+ for (int i = asd.getX(); i >= asd.getX() - minDistToDropLeft; i--) {
+ WaterNode nodehere = getNodeAt(i, asd.getY());
+ if (leverStates.contains(nodehere.getCondition()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition());
+ r.getNodes().add(nodehere);
+ WaterNode down = getNodeAt(i, asd.getY() + 1);
+ if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) {
+ toGoDownTo.add(down);
}
}
}
- startX = node.getX();
- prevY = currY;
}
}
+ LinkedList<LeverState> states = new LinkedList<LeverState>();
+ states.addAll(waterBlockingStates);
+ for (LeverState ls : leverStates) {
+ if (!states.contains(ls)) {
+ states.add(ls);
+ }
+ }
+ states.remove(null);
+
+ r.setConditionList(states);
+ return r;
}
+
public WaterNode getNodeAt(int x, int y) {
if (x < 0 || y < 0) return null;
if (x >= board[0].length || y >= board.length) return null;
@@ -272,22 +335,6 @@ public class WaterBoard {
toggleableMap.put("mainStream", waterNodeStart);
}
- // true if contradiction
- private boolean checkContradiction(Set<WaterCondition> conditions) {
- Map<String, Boolean> conditionMap = new HashMap<String, Boolean>();
- for (WaterCondition condition : conditions) {
- if (condition == null) continue;
- if (condition instanceof WaterConditionContradict) return true;
- if (conditionMap.containsKey(condition.getBlockId())) {
- if (conditionMap.get(condition.getBlockId()) != condition.isRequiredState())
- return true;
- } else {
- conditionMap.put(condition.getBlockId(), condition.isRequiredState());
- }
- }
- return false;
- }
-
private boolean isSwitchActive(SwitchData switchData) {
BlockPos switch2 = switchData.getSwitchLoc();
World w= waterPuzzle.getDungeonRoom().getContext().getWorld();
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java
index efd872bc..4a9b9534 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java
@@ -7,7 +7,7 @@ public interface WaterNode {
boolean canWaterGoThrough();
// condition for water go
- WaterCondition getCondition();
+ LeverState getCondition();
boolean isWaterFilled(World w);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java
index 265bebbe..cd07aa75 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java
@@ -1,6 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes;
-import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterCondition;
+import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState;
import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -19,7 +19,7 @@ public class WaterNodeAir implements WaterNode {
}
@Override
- public WaterCondition getCondition() {
+ public LeverState getCondition() {
return null;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java
index 2c047358..73a4f57d 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java
@@ -1,6 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes;
-import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterCondition;
+import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState;
import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -21,7 +21,7 @@ public class WaterNodeEnd implements WaterNode {
}
@Override
- public WaterCondition getCondition() {
+ public LeverState getCondition() {
return null;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java
index a25299c2..199e7ffb 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java
@@ -1,6 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes;
-import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterCondition;
+import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState;
import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -22,8 +22,8 @@ public class WaterNodeStart implements WaterNode {
}
@Override
- public WaterCondition getCondition() {
- return new WaterCondition("mainStream", !isReversed);
+ public LeverState getCondition() {
+ return new LeverState("mainStream", !isReversed);
}
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java
index aeddde9a..af30aca9 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java
@@ -1,6 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes;
-import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterCondition;
+import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState;
import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -23,8 +23,8 @@ public class WaterNodeToggleable implements WaterNode {
}
@Override
- public WaterCondition getCondition() {
- return new WaterCondition(blockId, invert);
+ public LeverState getCondition() {
+ return new LeverState(blockId, invert);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java
index 68b68df7..81329997 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java
@@ -1,6 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes;
-import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterCondition;
+import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState;
import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -20,7 +20,7 @@ public class WaterNodeWall implements WaterNode {
}
@Override
- public WaterCondition getCondition() {
+ public LeverState getCondition() {
return null;
}