Class TwistedLine
java.lang.Object
com.github.yellowstonegames.path.TwistedLine
Like
This generates a fully-connected graph for a given rectangular area, then solves it with
DrunkenWalk, this generates orthogonally-connected paths of Coord that meander through an area;
unlike DrunkenWalk, this won't ever generate paths that cross themselves.
This generates a fully-connected graph for a given rectangular area, then solves it with
DefaultGraph.findShortestPath(Coord, Coord, ObjectDeque, Heuristic).-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal DefaultGraphfinal com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> com.github.tommyettinger.random.EnhancedRandom -
Constructor Summary
ConstructorsConstructorDescriptionTwistedLine(int width, int height) TwistedLine(int width, int height, com.github.tommyettinger.random.EnhancedRandom rng) TwistedLine(int width, int height, com.github.tommyettinger.random.EnhancedRandom rng, com.github.yellowstonegames.grid.Coord[] traversable) TwistedLine(int width, int height, com.github.tommyettinger.random.EnhancedRandom rng, Collection<com.github.yellowstonegames.grid.Coord> traversable) -
Method Summary
Modifier and TypeMethodDescriptionintcom.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> Gets the last path this found, which may be empty.com.github.tommyettinger.random.EnhancedRandomgetRng()intgetWidth()com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> line(int startX, int startY, int endX, int endY) com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> line(com.github.yellowstonegames.grid.Coord start, com.github.yellowstonegames.grid.Coord end) voidCalled automatically during construction, this sets up a random maze as aDefaultGraphso a path can be found.voidCalled automatically during construction, this sets up a random maze as aDefaultGraphso a path can be found.voidreinitialize(com.github.yellowstonegames.grid.Coord[] traversable) This sets up a random maze as aDefaultGraphso a path can be found, using the given array of Coord to represent which cells on a 2D grid can actually be traversed (and so can be used in a random path).voidreinitialize(Collection<com.github.yellowstonegames.grid.Coord> traversable) This sets up a random maze as aDefaultGraphso a path can be found, using the given Collection of Coord to represent which cells on a 2D grid can actually be traversed (and so can be used in a random path).voidsetRng(com.github.tommyettinger.random.EnhancedRandom rng)
-
Field Details
-
rng
public com.github.tommyettinger.random.EnhancedRandom rng -
graph
-
lastPath
public final com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> lastPath
-
-
Constructor Details
-
TwistedLine
public TwistedLine() -
TwistedLine
public TwistedLine(int width, int height) -
TwistedLine
public TwistedLine(int width, int height, com.github.tommyettinger.random.EnhancedRandom rng) -
TwistedLine
public TwistedLine(int width, int height, com.github.tommyettinger.random.EnhancedRandom rng, Collection<com.github.yellowstonegames.grid.Coord> traversable) -
TwistedLine
public TwistedLine(int width, int height, com.github.tommyettinger.random.EnhancedRandom rng, com.github.yellowstonegames.grid.Coord[] traversable)
-
-
Method Details
-
reinitialize
public void reinitialize()Called automatically during construction, this sets up a random maze as aDefaultGraphso a path can be found. You can call this after construction to change the paths this can find. -
reinitialize
This sets up a random maze as aDefaultGraphso a path can be found, using the given Collection of Coord to represent which cells on a 2D grid can actually be traversed (and so can be used in a random path). Thetraversableparameter is often aRegion. You can call this after construction to change the paths this can find. -
reinitialize
public void reinitialize(com.github.yellowstonegames.grid.Coord[] traversable) This sets up a random maze as aDefaultGraphso a path can be found, using the given array of Coord to represent which cells on a 2D grid can actually be traversed (and so can be used in a random path). You can call this after construction to change the paths this can find. -
randomize
public void randomize()Called automatically during construction, this sets up a random maze as aDefaultGraphso a path can be found. You can call this after construction to change the paths this can find. -
line
public com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> line(int startX, int startY, int endX, int endY) -
line
public com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> line(com.github.yellowstonegames.grid.Coord start, com.github.yellowstonegames.grid.Coord end) -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getRng
public com.github.tommyettinger.random.EnhancedRandom getRng() -
setRng
public void setRng(com.github.tommyettinger.random.EnhancedRandom rng) -
getLastPath
public com.github.tommyettinger.ds.ObjectDeque<com.github.yellowstonegames.grid.Coord> getLastPath()Gets the last path this found, which may be empty. This returns the same reference to any path this produces, and the path is cleared when a new twisted line is requested. You probably want to copy the contents of this path into another list if you want to keep its contents.- Returns:
- the most recent path of Coord, as an ObjectDeque, this found.
-