Package math.wfc

Class Superposition

java.lang.Object
math.wfc.Superposition

public class Superposition extends Object
A Class storing a single superposition of multiple tiles.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Superposition(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 Type
    Method
    Description
    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.
    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
    Tests whether a given tile is still possible at this position.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Superposition

      public Superposition(int x, int y, Tile[] tileset)
      Constructor for a Superposition object.
      Parameters:
      x - the x-coordinate of the Superposition
      y - the y-coordinate of the Superposition
      tileset - the possibilities for the Superposition
    • Superposition

      public Superposition(int x, int y, Tile[] tileset, boolean[] possibilities)
      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 Superposition
      y - the y-coordinate of the Superposition
      tileset - the possibilities for the Superposition
      possibilities - the possibilities
  • Method Details

    • collapsePossibilities

      public boolean collapsePossibilities(Gridstate grid)
      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

      public Object clone()
      Overwrites the clone function inherited from Object.
      Overrides:
      clone in class Object
      Returns:
      Clone of the current Superposition
    • tilePossible

      public boolean tilePossible(Tile t)
      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

      public Tile 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