Node

data class Node(puzzleStatePair: StatePair, parent: Node?, g: Int, h: Int)

Data class corresponding to a node.

Parameters

puzzleStatePair

Current puzzle state (flattened into one dimension, following row-major order) and the position of the blank tile in the puzzle grid (zero-based, following row-major order).

parent

Parent of this node (null if this is the start node).

g

Cost of the path from the start node to this node (depth of this node).

h

Heuristic for estimating the cheapest path from this node to the goal (Manhattan distance).

Constructors

Node
Link copied to clipboard
fun Node(puzzleStatePair: StatePair, parent: Node?, g: Int, h: Int)
Current puzzle state (flattened into one dimension, following row-major order) and the position of the blank tile in the puzzle grid (zero-based, following row-major order).

Types

Companion
Link copied to clipboard
object Companion
Companion object containing the method for hashing the puzzle state of this node.

Properties

g
Link copied to clipboard
var g: Int
Cost of the path from the start node to this node (depth of this node).
h
Link copied to clipboard
private var h: Int
Heuristic for estimating the cheapest path from this node to the goal (Manhattan distance).
parent
Link copied to clipboard
val parent: Node?
Parent of this node (null if this is the start node).
puzzleStatePair
Link copied to clipboard
val puzzleStatePair: StatePair
Current puzzle state (flattened into one dimension, following row-major order) and the position of the blank tile in the puzzle grid (zero-based, following row-major order).

Functions

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this one.
getF
Link copied to clipboard
fun getF(): Int
Computes the f-value of this node (in relation to the A* algorithm).
hashCode
Link copied to clipboard
open override fun hashCode(): Int
Returns a hash code value for the object.