getManhattan

fun getManhattan(puzzleState: ArrayList<Int>, numColumns: Int, blankTileMarker: Int): Int

Computes the Manhattan distance of the given state vis-à-vis the goal state.

This value is computed as the sum of the Manhattan (straight-line) distances of the positions in the given state vis-à-vis the positions in the goal state.

Return

Manhattan distance of the given state vis-à-vis the goal state.

Parameters

puzzleState

Current puzzle state (flattened into one dimension, following row-major order).

numColumns

Number of columns in the puzzle grid.

blankTileMarker

Indicator that the tile is blank.