getPath

getPath(number start, number end, [array<integer> ignoredCells]) → array<integer> path
Finds a path between cell1 and cell2, avoiding occupied cells, except ignoredCells, which are considered empty even when an entity occupies them.

The starting cell cell1 is never included in the resulting path. The destination cell cell2 is included in the resulting path if and only if it is empty or ignored by ignoredCells.

If no path exists between the two cells, getPath returns null.

Returns the shortest path between two cells start and end that avoids obstacles, if there is one, ignoring the cells contained in the array ignoredCells.

The starting cell start is never part of the resulting path. The cell end is part of the resulting path if and only if it is empty or ignored by ignoredCells.

If no path exists between the two cells, getPath returns null.

Be careful: it is possible that getPath(start, end) != getPath(end, start).

Parameters
Return
Examples
var path = getPath(getCell(), getCell(enemy))
mark(path, COLOR_RED) // Shows the path between me and the enemy
const path = Field.path(Fight.me.cell, enemy.cell)
Debug.mark(path, Color.RED) // Shows the path between me and the enemy
path = Field.path(Fight.me.cell, enemy.cell)
Debug.mark(path, Color.RED)  # Shows the path between me and the enemy
See also