moveWhileValid

fun moveWhileValid(location: Location, vector: Vector, steps: Int, isValid: (Location) -> Boolean): Boolean

Move max steps into direction vector starting at location while the location is valid.

Return

Whether the movement was stopped because the next location was invalid.

Parameters

location

Starting location, which will be mutated.

vector

Direction vector to move in

steps

Maximum number of steps to move

isValid

Function to check if the new location is valid