Knight's tour: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Hendursaga (talk | contribs) 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 |
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 |
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 |
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. ;;; |