abstract away the specific attachment from the impl of a player physics tracking navigable surface
This commit is contained in:
74
src/main/java/baritone/builder/CountingSurface.java
Normal file
74
src/main/java/baritone/builder/CountingSurface.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.builder;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class CountingSurface extends NavigableSurface {
|
||||
public CountingSurface(int x, int y, int z) {
|
||||
super(x, y, z, Attachment::new, $ -> new Attachment());
|
||||
}
|
||||
|
||||
private static class Attachment {
|
||||
public final int surfaceSize;
|
||||
|
||||
public Attachment(Object a, Object b) {
|
||||
this((Attachment) a, (Attachment) b);
|
||||
}
|
||||
|
||||
public Attachment(Attachment a, Attachment b) {
|
||||
this.surfaceSize = a.surfaceSize + b.surfaceSize;
|
||||
}
|
||||
|
||||
public Attachment() {
|
||||
this.surfaceSize = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) { // used as performance optimization in RedBlackNode to avoid augmenting unchanged attachments
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Attachment)) {
|
||||
return false;
|
||||
}
|
||||
Attachment that = (Attachment) o;
|
||||
return surfaceSize == that.surfaceSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return surfaceSize;
|
||||
}
|
||||
}
|
||||
|
||||
public OptionalInt surfaceSize(BetterBlockPos pos) { // how big is the navigable surface from here? how many distinct coordinates can i walk to (in the future, the augmentation will probably have a list of those coordinates or something?)
|
||||
Object data = getComponentAugmentation(pos);
|
||||
if (data != null) { // i disagree with the intellij suggestion here i think it makes it worse
|
||||
return OptionalInt.of(((Attachment) data).surfaceSize);
|
||||
} else {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public int requireSurfaceSize(int x, int y, int z) {
|
||||
return surfaceSize(new BetterBlockPos(x, y, z)).getAsInt();
|
||||
}
|
||||
}
|
||||
21
src/main/java/baritone/builder/INavigableSurface.java
Normal file
21
src/main/java/baritone/builder/INavigableSurface.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.builder;
|
||||
|
||||
public interface INavigableSurface {
|
||||
}
|
||||
@@ -18,67 +18,28 @@
|
||||
package baritone.builder;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.builder.utils.com.github.btrekkie.connectivity.Augmentation;
|
||||
import baritone.builder.utils.com.github.btrekkie.connectivity.ConnGraph;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NavigableSurface {
|
||||
// the encapsulation / separation of concerns is not great, but this is better for testing purposes than the fully accurate stuff in https://github.com/cabaletta/baritone/tree/builder-2/src/main/java/baritone/builder lol
|
||||
public final CuboidBounds bounds;
|
||||
|
||||
private final CuboidBounds bounds;
|
||||
|
||||
private final BlockStateCachedData[] blocks;
|
||||
|
||||
private final ConnGraph connGraph;
|
||||
|
||||
public NavigableSurface(int x, int y, int z) {
|
||||
private final Function<BetterBlockPos, Object> genVertexAugmentation;
|
||||
|
||||
public NavigableSurface(int x, int y, int z, Augmentation augmentation, Function<BetterBlockPos, Object> genVertexAugmentation) {
|
||||
this.bounds = new CuboidBounds(x, y, z);
|
||||
this.blocks = new BlockStateCachedData[bounds.volume()];
|
||||
Arrays.fill(blocks, FakeStates.AIR);
|
||||
|
||||
this.connGraph = new ConnGraph(Attachment::new);
|
||||
}
|
||||
|
||||
public static class Attachment {
|
||||
public final int surfaceSize;
|
||||
|
||||
public Attachment(Object a, Object b) {
|
||||
this((Attachment) a, (Attachment) b);
|
||||
}
|
||||
|
||||
public Attachment(Attachment a, Attachment b) {
|
||||
this.surfaceSize = a.surfaceSize + b.surfaceSize;
|
||||
}
|
||||
|
||||
public Attachment() {
|
||||
this.surfaceSize = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) { // used as performance optimization in RedBlackNode to avoid augmenting unchanged attachments
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Attachment)) {
|
||||
return false;
|
||||
}
|
||||
Attachment that = (Attachment) o;
|
||||
return surfaceSize == that.surfaceSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return surfaceSize;
|
||||
}
|
||||
}
|
||||
|
||||
public OptionalInt surfaceSize(BetterBlockPos pos) { // how big is the navigable surface from here? how many distinct coordinates can i walk to (in the future, the augmentation will probably have a list of those coordinates or something?)
|
||||
Object data = connGraph.getComponentAugmentation(pos.toLong());
|
||||
if (data != null) { // i disagree with the intellij suggestion here i think it makes it worse
|
||||
return OptionalInt.of(((Attachment) data).surfaceSize);
|
||||
} else {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
this.genVertexAugmentation = genVertexAugmentation;
|
||||
this.connGraph = new ConnGraph(augmentation);
|
||||
}
|
||||
|
||||
// so the idea is that as blocks are added and removed, we'll maintain where the player can stand, and what connections that has to other places
|
||||
@@ -95,7 +56,7 @@ public class NavigableSurface {
|
||||
boolean currentlyAllowed = canPlayerStandIn(couldHaveChanged);
|
||||
if (currentlyAllowed) {
|
||||
// i'm sure this will get more complicated later
|
||||
connGraph.setVertexAugmentation(couldHaveChanged.toLong(), new Attachment());
|
||||
connGraph.setVertexAugmentation(couldHaveChanged.toLong(), genVertexAugmentation.apply(couldHaveChanged));
|
||||
} else {
|
||||
connGraph.removeVertexAugmentation(couldHaveChanged.toLong());
|
||||
}
|
||||
@@ -108,11 +69,11 @@ public class NavigableSurface {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlayerStandIn(BetterBlockPos where) {
|
||||
private boolean canPlayerStandIn(BetterBlockPos where) {
|
||||
return getBlockOrAir(where.down()) && !getBlockOrAir(where) && !getBlockOrAir(where.up());
|
||||
}
|
||||
|
||||
public void computePossibleMoves(BetterBlockPos feet) {
|
||||
private void computePossibleMoves(BetterBlockPos feet) {
|
||||
boolean anySuccess = canPlayerStandIn(feet);
|
||||
// even if all are fail, need to remove those edges from the graph, so don't return early
|
||||
for (int[] move : MOVES) {
|
||||
@@ -139,8 +100,8 @@ public class NavigableSurface {
|
||||
}
|
||||
}
|
||||
|
||||
public int requireSurfaceSize(int x, int y, int z) {
|
||||
return surfaceSize(new BetterBlockPos(x, y, z)).getAsInt();
|
||||
public CuboidBounds bounds() {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public boolean getBlock(BetterBlockPos where) {
|
||||
@@ -158,6 +119,10 @@ public class NavigableSurface {
|
||||
return connGraph.connected(a.toLong(), b.toLong());
|
||||
}
|
||||
|
||||
public Object getComponentAugmentation(BetterBlockPos pos) { // maybe should be protected? subclass defines it anyway
|
||||
return connGraph.getComponentAugmentation(pos.toLong());
|
||||
}
|
||||
|
||||
public void placeBlock(BetterBlockPos where) {
|
||||
placeOrRemoveBlock(where, true);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class NavigableSurfaceTest {
|
||||
@Test
|
||||
public void testBasic() {
|
||||
NavigableSurface surface = new NavigableSurface(10, 10, 10);
|
||||
CountingSurface surface = new CountingSurface(10, 10, 10);
|
||||
surface.placeBlock(0, 0, 0);
|
||||
assertEquals(OptionalInt.empty(), surface.surfaceSize(new BetterBlockPos(0, 0, 0)));
|
||||
assertEquals(1, surface.requireSurfaceSize(0, 1, 0));
|
||||
@@ -108,8 +108,8 @@ public class NavigableSurfaceTest {
|
||||
assertEquals(4, surface.requireSurfaceSize(2, 1, 0));
|
||||
}
|
||||
|
||||
private NavigableSurface makeFlatSurface(int width, int height) {
|
||||
NavigableSurface surface = new NavigableSurface(width, height, width);
|
||||
private CountingSurface makeFlatSurface(int width, int height) {
|
||||
CountingSurface surface = new CountingSurface(width, height, width);
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int z = 0; z < width; z++) {
|
||||
surface.placeBlock(new BetterBlockPos(x, 0, z));
|
||||
@@ -119,7 +119,7 @@ public class NavigableSurfaceTest {
|
||||
return surface;
|
||||
}
|
||||
|
||||
private NavigableSurface makeFlatSurface(int SZ) {
|
||||
private CountingSurface makeFlatSurface(int SZ) {
|
||||
return makeFlatSurface(SZ, SZ);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class NavigableSurfaceTest {
|
||||
public void testStep() {
|
||||
int SZ = 100;
|
||||
int lineAt = SZ / 2;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
for (int x = 0; x < SZ; x++) {
|
||||
surface.placeBlock(x, 1, lineAt); // doesn't block the player since you can step over 1 block
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class NavigableSurfaceTest {
|
||||
public void testBlocked() {
|
||||
int SZ = 100;
|
||||
int lineAt = SZ / 2;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
for (int x = 0; x < SZ; x++) {
|
||||
surface.placeBlock(x, 2, lineAt); // does block the player since you can't step over 2 blocks
|
||||
}
|
||||
@@ -163,15 +163,15 @@ public class NavigableSurfaceTest {
|
||||
assertEquals(SZ, surface.requireSurfaceSize(0, 3, lineAt));
|
||||
}
|
||||
|
||||
private void fillSurfaceInOrderMaintainingConnection(NavigableSurface surface, BetterBlockPos maintainConnectionTo, List<BetterBlockPos> iterationOrder) {
|
||||
private void fillSurfaceInOrderMaintainingConnection(CountingSurface surface, BetterBlockPos maintainConnectionTo, List<BetterBlockPos> iterationOrder) {
|
||||
fillSurfaceInOrderMaintainingConnection(surface, maintainConnectionTo, iterationOrder, false, false);
|
||||
}
|
||||
|
||||
private void fillSurfaceInOrderMaintainingConnection(NavigableSurface surface, BetterBlockPos maintainConnectionTo, List<BetterBlockPos> iterationOrder, boolean requirePathToPlacement, boolean allowSideSneakPlace) {
|
||||
private void fillSurfaceInOrderMaintainingConnection(CountingSurface surface, BetterBlockPos maintainConnectionTo, List<BetterBlockPos> iterationOrder, boolean requirePathToPlacement, boolean allowSideSneakPlace) {
|
||||
fillSurfaceInOrderMaintainingConnection(surface, maintainConnectionTo, iterationOrder, requirePathToPlacement, allowSideSneakPlace, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
private void fillSurfaceInOrderMaintainingConnection(NavigableSurface surface, BetterBlockPos maintainConnectionTo, List<BetterBlockPos> iterationOrder, boolean requirePathToPlacement, boolean allowSideSneakPlace, int stopAfter) {
|
||||
private void fillSurfaceInOrderMaintainingConnection(CountingSurface surface, BetterBlockPos maintainConnectionTo, List<BetterBlockPos> iterationOrder, boolean requirePathToPlacement, boolean allowSideSneakPlace, int stopAfter) {
|
||||
int qty = 0;
|
||||
outer:
|
||||
while (true) {
|
||||
@@ -215,12 +215,12 @@ public class NavigableSurfaceTest {
|
||||
}
|
||||
}
|
||||
|
||||
private String reportBottomToTop(NavigableSurface surface) {
|
||||
int len = surface.bounds.sizeY * ((surface.bounds.sizeX + 1) * surface.bounds.sizeZ + 1);
|
||||
private String reportBottomToTop(CountingSurface surface) {
|
||||
int len = surface.bounds().sizeY * ((surface.bounds().sizeX + 1) * surface.bounds().sizeZ + 1);
|
||||
StringBuilder report = new StringBuilder(len);
|
||||
for (int y = 0; y < surface.bounds.sizeY; y++) {
|
||||
for (int z = 0; z < surface.bounds.sizeZ; z++) {
|
||||
for (int x = 0; x < surface.bounds.sizeX; x++) {
|
||||
for (int y = 0; y < surface.bounds().sizeY; y++) {
|
||||
for (int z = 0; z < surface.bounds().sizeZ; z++) {
|
||||
for (int x = 0; x < surface.bounds().sizeX; x++) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(x, y, z)) ? 'X' : ' ');
|
||||
}
|
||||
report.append('\n');
|
||||
@@ -233,11 +233,11 @@ public class NavigableSurfaceTest {
|
||||
return report.toString();
|
||||
}
|
||||
|
||||
private String reportSlice(NavigableSurface surface, int y) {
|
||||
int len = (surface.bounds.sizeX + 1) * surface.bounds.sizeZ;
|
||||
private String reportSlice(CountingSurface surface, int y) {
|
||||
int len = (surface.bounds().sizeX + 1) * surface.bounds().sizeZ;
|
||||
StringBuilder report = new StringBuilder(len);
|
||||
for (int z = 0; z < surface.bounds.sizeZ; z++) {
|
||||
for (int x = 0; x < surface.bounds.sizeX; x++) {
|
||||
for (int z = 0; z < surface.bounds().sizeZ; z++) {
|
||||
for (int x = 0; x < surface.bounds().sizeX; x++) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(x, y, z)) ? 'X' : ' ');
|
||||
}
|
||||
report.append('\n');
|
||||
@@ -248,21 +248,21 @@ public class NavigableSurfaceTest {
|
||||
return report.toString();
|
||||
}
|
||||
|
||||
private static List<BetterBlockPos> genReportedWallOrder(NavigableSurface surface, int y) {
|
||||
List<BetterBlockPos> ret = new ArrayList<>((surface.bounds.sizeX + surface.bounds.sizeZ) * 2);
|
||||
for (int x = 0; x < surface.bounds.sizeX; x++) {
|
||||
private static List<BetterBlockPos> genReportedWallOrder(CountingSurface surface, int y) {
|
||||
List<BetterBlockPos> ret = new ArrayList<>((surface.bounds().sizeX + surface.bounds().sizeZ) * 2);
|
||||
for (int x = 0; x < surface.bounds().sizeX; x++) {
|
||||
ret.add(new BetterBlockPos(x, y, 0));
|
||||
}
|
||||
// start at 1 not 0 so that we don't repeat the last iteration of the previous loop (that would make the report look bad because the staircase would repeat one column for no reason)
|
||||
for (int z = 1; z < surface.bounds.sizeZ; z++) {
|
||||
ret.add(new BetterBlockPos(surface.bounds.sizeX - 1, y, z));
|
||||
for (int z = 1; z < surface.bounds().sizeZ; z++) {
|
||||
ret.add(new BetterBlockPos(surface.bounds().sizeX - 1, y, z));
|
||||
}
|
||||
// same deal for starting at -2 rather than -1
|
||||
for (int x = surface.bounds.sizeX - 2; x >= 0; x--) {
|
||||
ret.add(new BetterBlockPos(x, y, surface.bounds.sizeZ - 1));
|
||||
for (int x = surface.bounds().sizeX - 2; x >= 0; x--) {
|
||||
ret.add(new BetterBlockPos(x, y, surface.bounds().sizeZ - 1));
|
||||
}
|
||||
// and same again
|
||||
for (int z = surface.bounds.sizeZ - 2; z > 0; z--) {
|
||||
for (int z = surface.bounds().sizeZ - 2; z > 0; z--) {
|
||||
ret.add(new BetterBlockPos(0, y, z));
|
||||
}
|
||||
return ret;
|
||||
@@ -276,24 +276,24 @@ public class NavigableSurfaceTest {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private String reportAllFourWalls(NavigableSurface surface) {
|
||||
int len = surface.bounds.sizeY * (surface.bounds.sizeX + surface.bounds.sizeZ) * 2;
|
||||
private String reportAllFourWalls(CountingSurface surface) {
|
||||
int len = surface.bounds().sizeY * (surface.bounds().sizeX + surface.bounds().sizeZ) * 2;
|
||||
StringBuilder report = new StringBuilder(len);
|
||||
for (int y = surface.bounds.sizeY - 1; y >= 0; y--) {
|
||||
for (int y = surface.bounds().sizeY - 1; y >= 0; y--) {
|
||||
// make a report of what all four walls look like
|
||||
for (int x = 0; x < surface.bounds.sizeX - 1; x++) {
|
||||
for (int x = 0; x < surface.bounds().sizeX - 1; x++) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(x, y, 0)) ? 'X' : ' ');
|
||||
}
|
||||
report.append('|');
|
||||
for (int z = 0; z < surface.bounds.sizeZ - 1; z++) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(surface.bounds.sizeX - 1, y, z)) ? 'X' : ' ');
|
||||
for (int z = 0; z < surface.bounds().sizeZ - 1; z++) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(surface.bounds().sizeX - 1, y, z)) ? 'X' : ' ');
|
||||
}
|
||||
report.append('|');
|
||||
for (int x = surface.bounds.sizeX - 1; x > 0; x--) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(x, y, surface.bounds.sizeZ - 1)) ? 'X' : ' ');
|
||||
for (int x = surface.bounds().sizeX - 1; x > 0; x--) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(x, y, surface.bounds().sizeZ - 1)) ? 'X' : ' ');
|
||||
}
|
||||
report.append('|');
|
||||
for (int z = surface.bounds.sizeZ - 1; z > 0; z--) {
|
||||
for (int z = surface.bounds().sizeZ - 1; z > 0; z--) {
|
||||
report.append(surface.getBlock(new BetterBlockPos(0, y, z)) ? 'X' : ' ');
|
||||
}
|
||||
report.append('\n');
|
||||
@@ -309,7 +309,7 @@ public class NavigableSurfaceTest {
|
||||
// build a single wall, but, never place a block that disconnects the surface
|
||||
// (we expect to see a triangle)
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(0, 1, 1); // won't be involved in the wall (since z=1)
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = 0; y < SZ; y++) {
|
||||
@@ -343,11 +343,11 @@ public class NavigableSurfaceTest {
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX\n";
|
||||
assertEquals(shouldBe, reportAllFourWalls(surface));
|
||||
|
||||
NavigableSurface surface2 = makeFlatSurface(SZ);
|
||||
CountingSurface surface2 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface2, someOtherBlock, order, true, false); // this one also works in strict jump placement mode
|
||||
assertEquals(shouldBe, reportAllFourWalls(surface2));
|
||||
|
||||
NavigableSurface surface3 = makeFlatSurface(SZ);
|
||||
CountingSurface surface3 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface3, someOtherBlock, order, true, true); // sneak doesn't help either
|
||||
assertEquals(shouldBe, reportAllFourWalls(surface3));
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class NavigableSurfaceTest {
|
||||
// build four walls, but, never place a block that disconnects the surface
|
||||
// (we expect to see a carved path for the player from bottom to top)
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = 0; y < SZ; y++) {
|
||||
@@ -398,7 +398,7 @@ public class NavigableSurfaceTest {
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX\n";
|
||||
assertEquals(shouldBe, reportAllFourWalls(surface));
|
||||
|
||||
NavigableSurface surface2 = makeFlatSurface(SZ);
|
||||
CountingSurface surface2 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface2, someOtherBlock, order, true, false);
|
||||
String shouldBeWithJump = "" +
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXX | XX|XXXXXXXXXXXXXXXXXXX\n" + // if we're only allowed to jump place, the overhang is no longer possible (since it requires sneak side place)
|
||||
@@ -423,7 +423,7 @@ public class NavigableSurfaceTest {
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX\n";
|
||||
assertEquals(shouldBeWithJump, reportAllFourWalls(surface2));
|
||||
|
||||
NavigableSurface surface3 = makeFlatSurface(SZ);
|
||||
CountingSurface surface3 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface3, someOtherBlock, order, true, true);
|
||||
assertEquals(shouldBe /* but if side place is allowed, we can make the full shape! */, reportAllFourWalls(surface3));
|
||||
}
|
||||
@@ -431,7 +431,7 @@ public class NavigableSurfaceTest {
|
||||
@Test
|
||||
public void testCastleFourWallsLoopOrder() {
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = 0; y < SZ; y++) {
|
||||
@@ -471,7 +471,7 @@ public class NavigableSurfaceTest {
|
||||
// this creates a cool shape :)
|
||||
int SZ = 20;
|
||||
for (int heightTest = 0; heightTest < 3; heightTest++) {
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = SZ - 1 - heightTest; y >= 0; y--) {
|
||||
@@ -551,7 +551,7 @@ public class NavigableSurfaceTest {
|
||||
continue;
|
||||
}
|
||||
|
||||
NavigableSurface surface2 = makeFlatSurface(SZ);
|
||||
CountingSurface surface2 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface2, someOtherBlock, order, true, false);
|
||||
String shouldBeV = "" +
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|X \n" +
|
||||
@@ -577,7 +577,7 @@ public class NavigableSurfaceTest {
|
||||
assertEquals(shouldBeV, reportAllFourWalls(surface2));
|
||||
|
||||
|
||||
NavigableSurface surface3 = makeFlatSurface(SZ);
|
||||
CountingSurface surface3 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface3, someOtherBlock, order, true, true, 69);
|
||||
// PARTIAL FILL, purely to demonstrate the order
|
||||
String shouldBeStaircasePartial69 = "" +
|
||||
@@ -658,7 +658,7 @@ public class NavigableSurfaceTest {
|
||||
public void testCastleFourWallsTopToBottom() {
|
||||
// same as previous except in Z X iteration order, this causes some FUNKY shapes to appear and I think it's cool
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = SZ - 1; y >= 0; y--) {
|
||||
@@ -701,7 +701,7 @@ public class NavigableSurfaceTest {
|
||||
// waow, so cool!
|
||||
assertEquals(shouldBe, reportAllFourWalls(surface));
|
||||
|
||||
NavigableSurface surface2 = makeFlatSurface(SZ);
|
||||
CountingSurface surface2 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface2, someOtherBlock, order, true, false, 500);
|
||||
String shouldBeVPartial500 = "" +
|
||||
"XXXXXXXXXXXXX | | | \n" + // you can see how the iteration order causes it to fill in from both side, eventually causing a V in the middle
|
||||
@@ -774,7 +774,7 @@ public class NavigableSurfaceTest {
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX\n";
|
||||
assertEquals(shouldBeV, reportAllFourWalls(surface2));
|
||||
|
||||
NavigableSurface surface3 = makeFlatSurface(SZ);
|
||||
CountingSurface surface3 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface3, someOtherBlock, order, true, true, 500);
|
||||
String shouldBeWeirdPartial500 = "" +
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXX XXXXXXXXXXXXX\n" +
|
||||
@@ -835,7 +835,7 @@ public class NavigableSurfaceTest {
|
||||
// just a small variant with no corner, so there's no wraparound
|
||||
// not that interesting
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = SZ - 1; y >= 0; y--) {
|
||||
@@ -879,7 +879,7 @@ public class NavigableSurfaceTest {
|
||||
"XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX|XXXXXXXXXXXXXXXXXXX\n";
|
||||
assertEquals(shouldBe, reportAllFourWalls(surface));
|
||||
|
||||
NavigableSurface surface2 = makeFlatSurface(SZ);
|
||||
CountingSurface surface2 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface2, someOtherBlock, order, true, false);
|
||||
String shouldBeV = "" +
|
||||
" XXXXXXXXXXXXXXXXXX|XXX | |XXXXXXXXXXXXXXXXXXX\n" +
|
||||
@@ -905,7 +905,7 @@ public class NavigableSurfaceTest {
|
||||
// ^ notice how the left column is gone
|
||||
assertEquals(shouldBeV, reportAllFourWalls(surface2));
|
||||
|
||||
NavigableSurface surface3 = makeFlatSurface(SZ);
|
||||
CountingSurface surface3 = makeFlatSurface(SZ);
|
||||
fillSurfaceInOrderMaintainingConnection(surface3, someOtherBlock, order, true, true);
|
||||
assertEquals(shouldBeV /* sneak doesn't help without loop around through {x=0 z=0} corner*/, reportAllFourWalls(surface3));
|
||||
}
|
||||
@@ -917,7 +917,7 @@ public class NavigableSurfaceTest {
|
||||
// but also an interior ring at y=8, filled afterwards
|
||||
// because it's filled afterwards, it only allows for one extra block to be placed at y=9
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = 0; y < SZ; y++) {
|
||||
@@ -975,7 +975,7 @@ public class NavigableSurfaceTest {
|
||||
// (we expect to see a zigzag cut out)
|
||||
// but also an interior ring at y=8, filled beforehand
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int x = 0; x < SZ; x++) {
|
||||
@@ -1033,7 +1033,7 @@ public class NavigableSurfaceTest {
|
||||
// (we expect to see a zigzag cut out)
|
||||
// but also an interior # shape at y=8, filled afterwards
|
||||
int SZ = 20;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(SZ / 2, 1, SZ / 2); // center of the courtyard
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int x = 0; x < SZ; x++) {
|
||||
@@ -1112,7 +1112,7 @@ public class NavigableSurfaceTest {
|
||||
public void testFullCube() {
|
||||
int width = 10;
|
||||
int height = 30;
|
||||
NavigableSurface surface = makeFlatSurface(width, height);
|
||||
CountingSurface surface = makeFlatSurface(width, height);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(0, 1, width / 2);
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = 0; y < height; y++) {
|
||||
@@ -1174,7 +1174,7 @@ public class NavigableSurfaceTest {
|
||||
@Test
|
||||
public void testFullCubeRandom() {
|
||||
int SZ = 10;
|
||||
NavigableSurface surface = makeFlatSurface(SZ);
|
||||
CountingSurface surface = makeFlatSurface(SZ);
|
||||
BetterBlockPos someOtherBlock = new BetterBlockPos(0, 1, 0);
|
||||
List<BetterBlockPos> order = new ArrayList<>();
|
||||
for (int y = 0; y < SZ; y++) {
|
||||
|
||||
Reference in New Issue
Block a user