Do you remember the classic mission Open Labyrinth? Well, you once again find yourself inside a labyrinth, but the lights are out and you cannot see the full map. You have flashlight and know that all passages in the Labyrinth are directed along South-North and East-West lines. You don't yet know your position or the location of the exit. You must hurry as you cannot run forever.
This is a "multicall" mission and as such, your function will be called until you have solved the maze or run out of moves. For each iteration you see a part of the labyrinth in four directions (function input). You can see passages and where they have crossings and turns. If it’s in your range of vision, you’ll see the exit too. The visible zones are represented as a grid as a tuple of strings, where "X" is a wall, "." is a passage cell, "?" is unknown, "P" is player and "E" is... Grids are represented as 2D rectangular arrays. The size is related to size of the visible zone.