main
Matthew Butterick 10 years ago
parent 8f18a8c6a9
commit d2e27edafc

@ -111,8 +111,12 @@ This class describes finite-domain Constraint Satisfaction Problems.
(define result null)
(for ([val (in-list (hash-ref domains var))])
(when (= (nconflicts var val assignment) 0)
;; what does this mean?
;; a = assignment.copy; a[var] = val
(define a (hash-copy assignment)) ;; !! typo fix in original
(hash-set! a var val)
(set! result (append result (cons (cons var val) a)))))
result)))
;; todo: calls to append need to mutate.
@ -124,7 +128,7 @@ This class describes finite-domain Constraint Satisfaction Problems.
#|
#|
(define (actions csp state)
;; Return a list of applicable actions: nonconflicting
;; assignments to an unassigned variable.
@ -137,7 +141,7 @@ This class describes finite-domain Constraint Satisfaction Problems.
(filter (λ(val) (= 0 (nconflicts csp var val assignment))) (hash-ref (hash-ref csp 'domains) var))))))
|#
#|
#|
def actions(self, state):
"""Return a list of applicable actions: nonconflicting
@ -530,4 +534,3 @@ def solve_zebra(algorithm=min_conflicts, **args):
|#
Loading…
Cancel
Save