Knight's tour: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
m (Minor spelling fixes.)
Line 2,600: Line 2,600:
This interactive program will ask for a starting case in algebraic notation and, also, whether a closed tour is desired. Each next move is selected according to Warnsdorff's rule; ties are broken at random.
This interactive program will ask for a starting case in algebraic notation and, also, whether a closed tour is desired. Each next move is selected according to Warnsdorff's rule; ties are broken at random.


The closed tour algorithm is quite crude: just find tours over and over until one happens to be closed by chance.
The closed tour algorithm is quite crude: just find tours over and over until one happens to be closed by chance.


This code is quite verbose: I tried to make it easy for myself and for other to follow and understand. I'm not a Lisp expert, so I probably missed some idiomatic shortcuts I could have used to make it shorter.
This code is quite verbose: I tried to make it easy for myself and for others to follow and understand. I'm not a Lisp expert, so I probably missed some idiomatic shortcuts I could have used to make it shorter.


For some reason, the interactive part does not work with sbcl, but it works fine wit clisp.
For some reason, the interactive part does not work with SBCL, but it works fine with CLISP.
<syntaxhighlight lang="lisp">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
<syntaxhighlight lang="lisp">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Solving the knight's tour. ;;;
;;; Solving the knight's tour. ;;;