fix: improve pathfinding test
This commit is contained in:
parent
1601a2560d
commit
b80b96a3a0
@ -208,23 +208,17 @@ class GameLogicTest {
|
||||
|
||||
ArrayList<IntVector2> result = GameLogic.Bresenham4Connected(a, b);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int y = 0; y < size; y++) {
|
||||
for(int x = 0; x < size; x++) {
|
||||
IntVector2 pos = new IntVector2(x, y);
|
||||
assertEquals(result.get(0), a, "Start point should be point A");
|
||||
assertEquals(result.get(result.size() - 1), b, "End point should be point B");
|
||||
|
||||
IntVector2 old = a;
|
||||
for(IntVector2 pos: result) {
|
||||
if(pos.equals(a)) {
|
||||
sb.append("A ");
|
||||
}else if(pos.equals(b)) {
|
||||
sb.append("B ");
|
||||
}else if(result.contains(pos)) {
|
||||
sb.append("o ");
|
||||
}else {
|
||||
sb.append(". ");
|
||||
continue;
|
||||
}
|
||||
assertEquals(1, old.distanceManhattan(pos), "Distance between every step should be 1");
|
||||
old = pos;
|
||||
}
|
||||
sb.append("\n");
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user