@karelpeeters - That looks v similar to my implementation except that I use a lazy Map with a getOrPut() method to represent the grid.
Got the right answer for Part 1 & my Grid looks to be correct but I get an answer of 44 rather than 45 for the example in Part 2.
I was getting a lower answer but I missed the fact that the explorer needs to be holding the Torch when they reach the target.
I have got a slight tweak to attempt to reduce the number of states visited by using (elapsedTime + distanceToTarget) as the comparator like
tentativeDistance
in the A* algorithm.