I wrote the following code using the method of finding where the horse can go in the chess board:
matrix = {{3, 6, 9}, {12, 15, 18}, {21, 24,
27}};
value = 15;(*The value of the central element*)
{m, n} = Dimensions[matrix];
Board = Table[0, {m + 1}, {n + 1}];
Moves0 = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
Moves = Nest[
DeleteDuplicates[Flatten[Outer[Plus, #, Moves0, 1], 1]] &, {{0,
0}}, 1(*step number*)];
InRangeAndEmpty[{x_, y_}] := (1 <= x <= m && 1 <= y <= n &&
Board[[x, y]] == 0);
Accessibility[{x_, y_}] :=
Module[{accessibility = 0, a = 1},
While[a <= 8,
If[InRangeAndEmpty[{x + Moves[[a, 1]], y + Moves[[a, 2]]}],
accessibility++]; a++];
accessibility];
GetNextMove[{x_, y_}] :=
MapIndexed[{First[#2], #1} &,
SortBy[Select[
Table[{x + Moves[[i, 1]], y + Moves[[i, 2]]}, {i,
Length[Moves]}], InRangeAndEmpty],
N@Arg[#[[2]] - x + (#[[1]] - y) I] &]];
matrix[[#1, #2]] & @@@ (GetNextMove[
Position[matrix, value] // First][[All, 2]])
MatrixForm[
MapAt[Highlighted[#, Background -> Red] &,
MapAt[Highlighted, #, First[Position[matrix, value]]],
GetNextMove[
Position[#, value(The value of the central element)] //
First][[All, 2]]]] &@matrix


If you need periodic filling, you only need to increase some feasible ways of moves:
Moves0 = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {m - 1, 0}, {-(m - 1),
0}, {0, -(n - 1)}, {0, n - 1}};
Moves0 = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {m - 1, 0}, {-(m - 1),
0}, {0, -(n - 1)}, {0, n - 1}};
matrix = {{4, 8, 12, 16}, {20, 24, 28, 32}, {36, 40, 44, 48}, {52, 56,
60, 64}};
position = {1, 1};(*The position of the central element*)
{m, n} = Dimensions[matrix];
Board = Table[0, {m + 1}, {n + 1}];
Moves0 = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {m - 1, 0}, {-(m - 1),
0}, {0, -(n - 1)}, {0, n - 1}};
Moves = Nest[
DeleteDuplicates[Flatten[Outer[Plus, #, Moves0, 1], 1]] &, {{0,
0}}, 1(*step number*)];
InRangeAndEmpty[{x_, y_}] := (1 <= x <= m && 1 <= y <= n &&
Board[[x, y]] == 0);
Accessibility[{x_, y_}] :=
Module[{accessibility = 0, a = 1},
While[a <= 8,
If[InRangeAndEmpty[{x + Moves[[a, 1]], y + Moves[[a, 2]]}],
accessibility++]; a++];
accessibility];
GetNextMove[{x_, y_}] :=
MapIndexed[{First[#2], #1} &,
SortBy[Select[
Table[{x + Moves[[i, 1]], y + Moves[[i, 2]]}, {i,
Length[Moves]}], InRangeAndEmpty],
N@Arg[#[[2]] - x + (#[[1]] - y) I] &]];
matrix[[#1, #2]] & @@@ (GetNextMove[position][[All, 2]])
MatrixForm[
MapAt[Highlighted[#, Background -> Red] &,
MapAt[Highlighted, #,
position(The position of the central element)],
GetNextMove[position][[All, 2]]]] &@matrix

Reference link:趣味象棋 一马平川
https://demonstrations.wolfram.com/TheKnightsTour/
ArrayPad[m, {1,1},"Periodic"]to generate a version of your array with wraparound padding, then extract the neighbors in that matrix. Remember to adjust the indices inside your function. – MarcoB Feb 06 '21 at 13:40