








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









CSCI 5582, Fall 2007
In Scheme: (define (minimax gamestate myfunction otherfunction level) (cond ((= level 0) (getvalue gamestate)) (else (let* ((successors (getnextmoves gamestate)) (othervals (map (lambda (successor) (minimax successor otherfunction myfunction (- level 1))) successors))) (apply myfunction othervals)))))
(define (alpha-beta alpha beta level node max?) (cond ((= level 0) (static-value node)) (max? (let ((children (find-next-moves node #t))) (max-look-at-each-child-node children alpha beta level))) (else (let ((children (find-next-moves node #f))) (min-look-at-each-child-node children alpha beta level))))) (define (max-look-at-each-child-node children alpha beta level) (cond ((null? children) alpha) ((>= alpha beta) alpha) (else (let ((next-value (alpha-beta alpha beta (- level 1) (first children) #f))) (max-look-at-each-child-node (rest children) (max next-value alpha) beta level))))) (define (min-look-at-each-child-node children alpha beta level) (cond ((null? children) beta) ((>= alpha beta) beta) (else (let ((next-value (alpha-beta alpha beta (- level 1) (first children) #t))) (min-look-at-each-child-node (rest children) alpha (min next-value beta) level)))))
Calling alpha-beta with starting values of a (very low) alpha value, a (very high) beta value, a depth of 5, the starting game state, and from the point of view of the maximizer. (alpha-beta -1000 1000 5 initial-game-state #t)