Created
December 1, 2011 21:25
-
-
Save samth/1419997 to your computer and use it in GitHub Desktop.
https://www.ai-class.com/course/video/videolecture/160 1:31 maxValue in racket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; lower-bound = alpha | |
; upper-bound = beta | |
(define (maximum-value-with-cutoff s depth lower-bound upper-bound) | |
(let-values | |
([(maximum-value new-lower-bound within-upper-bound?) | |
(for*/fold | |
([maximum-so-far -inf.0] | |
[new-lower-bound lower-bound]) | |
([successor (successors s)] | |
[successor-value (in-value (value-with-cutoff successor | |
(add1 depth) | |
new-lower-bound | |
upper-bound))] | |
#:when (< successor-value upper-bound)) | |
(values | |
(max maximum-so-far successor-value) | |
(max new-lower-bound successor-value)))]) | |
maximum-value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment