Closed Knight's Tour in SWI Prolog



Download Prolog code: knight.pl


You need SWI-Prolog >= 5.8.0 (recommended: latest git version). Start it with
      swipl -f knight.pl
    

Example queries that you can try:

      ?- n_tour(N, Ts), maplist(label, Ts).

      ?- n_tour(N, Ts), maplist(label, Ts), print_tour(Ts).

      ?- show(8, [ff], Ts).

      ?- show(N, [ff], Ts), print_tour(Ts).
    


Sample pictures for N = 6, 8, 12, 16:

  


  


Challenges: Find solutions for large boards. Find good labeling and allocation strategies. ...

Main page