When you control the pawn in the maze, to reach the exit, that is fantastic @Keying Huang you could do that with character codes! Reading about your bug in the algorithm, I felt algorithmic. I was so elated to see and so when I was in the maze I saw all those shimmering lines of sight @Keying Huang you were talking about, when the knights can only see the pawn when they enter its line of sight. I had a lot of fun.
mazeArray = Array[0 &, {100, 100}];
addRandomWalls[array_, wallDensity_] := Module[{newArray = array},
Do[If[(i > 35 && i < 66 && j > 35 && j < 66 && Mod[i, 2] == 0 &&
Mod[j, 2] == 0) ||
(Mod[2*i*j + i + j, 3] == 1 && RandomReal[] < wallDensity),
newArray[[i, j]] = 1],
{i, 100}, {j, 100}
]; newArray]
mazeArray = addRandomWalls[mazeArray, 0.4];
adjGraph = NearestNeighborGraph[Position[mazeArray, 0], {All, 1}];
DynamicModule[{vertex = VertexList[adjGraph][[1]]},
EventHandler[
Dynamic@ArrayPlot[ReplacePart[mazeArray, vertex -> 2],
ColorRules -> {0 -> White, 1 -> RGBColor["#00FFFF"]},
ImageSize -> Large,
PlotRangePadding ->
0.2], {"UpArrowKeyDown" :> (vertex =
If[MemberQ[VertexList[adjGraph], vertex + #1], vertex + #1,
vertex];),
"DownArrowKeyDown" :> (vertex =
If[MemberQ[VertexList[adjGraph], vertex + #2], vertex + #2,
vertex];),
"LeftArrowKeyDown" :> (vertex =
If[MemberQ[VertexList[adjGraph], vertex + #3], vertex + #3,
vertex];),
"RightArrowKeyDown" :> (vertex =
If[MemberQ[VertexList[adjGraph], vertex + #4], vertex + #4,
vertex];)} &[{-1, 0}, {1, 0}, {0, -1}, {0, 1}]]]
Fun is important! Making these dynamic objects available, @Keying Huang. Exploring the cavernous paths of your maze was a delight.
Is it possible for the characters to just communicate via echo-location and develop some sort of "line of sight" further and reach the exit that way?
Those DynamicModules and EventHandlers, it's that knight walk graph @Keying Huang .