From 1a81811aca4912c53a1993965ef520f594e7199d Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 6 Oct 2014 21:27:55 -0700 Subject: [PATCH] add note --- csp/solver.rkt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/csp/solver.rkt b/csp/solver.rkt index 491f9104..c57b9589 100644 --- a/csp/solver.rkt +++ b/csp/solver.rkt @@ -21,6 +21,20 @@ (set! vvps (cdr vvps)) (values (vvp-variable vvp) (vvp-values vvp) (vvp-pushdomains vvp))))) +#| +(define (recursive-backtracking assignment csp) + (if (complete? assignment) + assignment + (let ([var (select-unassigned-variable csp-variables, assignment, csp)]) + (for/or ([value (in-list (order-domain-values var assignment csp))]) + if ((value . consistent-with? . assignment csp-constraints)) + (add-to assignment var value) + (define result (recursive-backtracking assignment csp)) + (when result + (and result (remove-from assignment var value))) + #f)))) +|# + (define backtracking-solver% ;; Problem solver with backtracking capabilities (class solver%