Function: 5x5-crack
5x5-crack is an autoloaded, interactive and byte-compiled function
defined in 5x5.el.gz.
Signature
(5x5-crack BREEDER)
Documentation
Attempt to find a solution for 5x5.
5x5-crack takes the argument BREEDER which should be a function that takes
two parameters, the first will be a grid vector array that is the current
solution and the second will be the best solution so far. The function
should return a grid vector array that is the new solution.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/play/5x5.el.gz
;;;###autoload
(defun 5x5-crack (breeder)
"Attempt to find a solution for 5x5.
`5x5-crack' takes the argument BREEDER which should be a function that takes
two parameters, the first will be a grid vector array that is the current
solution and the second will be the best solution so far. The function
should return a grid vector array that is the new solution."
(interactive "aBreeder function: ")
(5x5)
(setq 5x5-cracking t)
(let* ((best-solution (5x5-make-random-grid))
(current-solution best-solution)
(best-result (5x5-make-new-grid))
(current-result (5x5-make-new-grid))
(target (* 5x5-grid-size 5x5-grid-size)))
(while (and (< (5x5-grid-value best-result) target)
(not (input-pending-p)))
(setq current-result (5x5-play-solution current-solution best-solution))
(if (> (5x5-grid-value current-result) (5x5-grid-value best-result))
(setq best-solution current-solution
best-result current-result))
(setq current-solution (funcall breeder
(5x5-copy-grid current-solution)
(5x5-copy-grid best-solution)))))
(setq 5x5-cracking nil))