BFS

class BFS(startingPoint: TileInfo, predicate: (TileInfo) -> Boolean)

Defines intermediate steps of a breadth-first search, for use in either get shortest path or get connected tiles.

Constructors

BFS
Link copied to clipboard
fun BFS(startingPoint: TileInfo, predicate: (TileInfo) -> Boolean)

Functions

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
getPathTo
Link copied to clipboard
fun getPathTo(destination: TileInfo): Sequence<TileInfo>
getReachedTiles
Link copied to clipboard
fun getReachedTiles(): MutableSet<TileInfo>
hasEnded
Link copied to clipboard
fun hasEnded(): Boolean
hashCode
Link copied to clipboard
open fun hashCode(): Int
hasReachedTile
Link copied to clipboard
fun hasReachedTile(tile: TileInfo): Boolean
nextStep
Link copied to clipboard
fun nextStep()

Process one tile-to-search, fetching all neighbors not yet touched and adding those that fulfill the predicate to the reached set and to the yet-to-be-processed set.

size
Link copied to clipboard
fun size(): Int
stepToEnd
Link copied to clipboard
fun stepToEnd()

Process fully until there's nowhere left to check

stepUntilDestination
Link copied to clipboard
fun stepUntilDestination(destination: TileInfo): BFS

Process until either destination is reached or there's nowhere left to check

toString
Link copied to clipboard
open fun toString(): String

Properties

maxSize
Link copied to clipboard
var maxSize: Int

Maximum number of tiles to search

predicate
Link copied to clipboard
private val predicate: (TileInfo) -> Boolean
startingPoint
Link copied to clipboard
val startingPoint: TileInfo
tilesReached
Link copied to clipboard
private val tilesReached: HashMap<TileInfo, TileInfo>

each tile reached points to its parent tile, where we got to it from

tilesToCheck
Link copied to clipboard
private val tilesToCheck: ArrayDeque<TileInfo>

remaining tiles to check

Sources

jvm source
Link copied to clipboard