This is a Dijkstra's algorithm implementation in Prolog.
The idea is to move the chess knight from cell (x1,y1) to cell (x2,y2) with the minimum number of moves.
That's exactly what Dijkstra does in a connected graph.
Here, the cells of the chess border are the nodes.
The code for chess knight, and some other examples in Prolog are available here:
https://github.com/dbeqiraj/prolog