Package math.wfc
Class Superposition
java.lang.Object
math.wfc.Superposition
A Class storing a single superposition of multiple tiles.
-
Constructor Summary
ConstructorsConstructorDescriptionSuperposition
(int x, int y, Tile[] tileset) Constructor for a Superposition object.Superposition
(int x, int y, Tile[] tileset, boolean[] possibilities) Constructor for a Superposition object with possibilities given. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Overwrites the clone function inherited from Object.boolean
Collapses possibilities for the position.void
collapseTo
(int possibility) Collapses the Superposition to one possibility.void
collapseToFromPossible
(int possibility) Collapses the Superposition to one of the still possible states.int
Gets the count of possibilities left for the Position.getTile()
Gets the tile a Superposition has collapsed to.boolean
To test if the wave function has fully collapsed in this position (equivalent to getPossibilityCount() == 1).boolean
tilePossible
(Tile t) Tests whether a given tile is still possible at this position.
-
Constructor Details
-
Superposition
Constructor for a Superposition object.- Parameters:
x
- the x-coordinate of the Superpositiony
- the y-coordinate of the Superpositiontileset
- the possibilities for the Superposition
-
Superposition
Constructor for a Superposition object with possibilities given. If the dimensions of tileset and possibilities mismatch the given possibilities parameter will be ignored.- Parameters:
x
- the x-coordinate of the Superpositiony
- the y-coordinate of the Superpositiontileset
- the possibilities for the Superpositionpossibilities
- the possibilities
-
-
Method Details
-
collapsePossibilities
Collapses possibilities for the position.- Parameters:
grid
- The grid of Superpositions- Returns:
- Whether or not anything was collapsed
-
collapseToFromPossible
public void collapseToFromPossible(int possibility) Collapses the Superposition to one of the still possible states. If the given parameter is higher than the number of possible States left (or less than 0) the Superposition will be empty afterwards.- Parameters:
possibility
- The index of the State to collapse to
-
collapseTo
public void collapseTo(int possibility) Collapses the Superposition to one possibility.- Parameters:
possibility
- The index of the State to collapse to
-
getPossibilityCount
public int getPossibilityCount()Gets the count of possibilities left for the Position.- Returns:
- Count of possibilities remaining
-
isCollapsed
public boolean isCollapsed()To test if the wave function has fully collapsed in this position (equivalent to getPossibilityCount() == 1).- Returns:
- Whether or not the Position is fully collapsed
-
clone
Overwrites the clone function inherited from Object. -
tilePossible
Tests whether a given tile is still possible at this position.- Parameters:
t
- The tile to test for- Returns:
- true if it is still possible
-
getTile
Gets the tile a Superposition has collapsed to.- Returns:
- Returns the tile a Superposition has collapsed to or null if it hasn't collapsed
-