Not a problem in trading code, maybe send me a private message so that we don't put it in the comments, anyway what I do is using a Dijkstra algorithm ( pseudocode here: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode ) to find the shortest path to the player, but I removed from the graph of vertices all of those that already has an enemy on it, if at any point the queue of nodes to visit is empty or the min distance is > 64 (since my board was 8x8 and I didn't know if it was possible to do <variable> == INF as a check) then I return an empty array, and an enemy moves only if the array has a dimension > 2 (since 2 is a path that includes the starting node and the arrival node).
Also don't add a neighbour node to the list at line 13-14 of the pseudocode if the node is in the nodes to avoid.