Terminal Pieces

This commit is contained in:
Daniel Mills 2021-01-10 09:00:18 -05:00
parent 125f705a6a
commit 2afb468ae4
2 changed files with 19 additions and 1 deletions

View File

@ -60,4 +60,8 @@ public class IrisJigsawPiece extends IrisRegistrant
return p; return p;
} }
public boolean isTerminal() {
return connectors.size() == 1;
}
} }

View File

@ -19,9 +19,11 @@ public class PlannedStructure {
private KMap<String, IrisObject> objectRotationCache; private KMap<String, IrisObject> objectRotationCache;
private RNG rng; private RNG rng;
private boolean verbose; private boolean verbose;
private boolean terminating;
public PlannedStructure(IrisJigsawStructure structure, IrisPosition position, RNG rng) public PlannedStructure(IrisJigsawStructure structure, IrisPosition position, RNG rng)
{ {
terminating = false;
objectRotationCache = new KMap<>(); objectRotationCache = new KMap<>();
verbose = true; verbose = true;
this.pieces = new KList<>(); this.pieces = new KList<>();
@ -186,7 +188,14 @@ public class PlannedStructure {
{ {
for(String j : getData().getJigsawPoolLoader().load(i).getPieces().shuffleCopy(rng)) for(String j : getData().getJigsawPoolLoader().load(i).getPieces().shuffleCopy(rng))
{ {
p.addIfMissing(getData().getJigsawPieceLoader().load(j)); IrisJigsawPiece pi = getData().getJigsawPieceLoader().load(j);
if(terminating && !pi.isTerminal())
{
continue;
}
p.addIfMissing(pi);
} }
} }
@ -198,6 +207,11 @@ public class PlannedStructure {
} }
private void generateTerminators() { private void generateTerminators() {
if(getStructure().isTerminate())
{
terminating = true;
generateOutwards(structure.getMaxDepth());
}
} }
public KList<PlannedPiece> getPiecesWithAvailableConnectors() public KList<PlannedPiece> getPiecesWithAvailableConnectors()