The code is the following:

- Code: Select all
`(defun minimax-alpha-beta (nodo alpha beta)`

(cond

((hoja nodo)

(let ((val (evalua nodo)))

(format t "~A " val)

val))

((nodo-min nodo)

(let ((beta-tmp beta))

(do ((ch (hijos nodo) (cdr ch)))

((or (null ch) (<= beta-tmp alpha)) beta-tmp)

(let ((r (minimax-alpha-beta (car ch) alpha beta-tmp)))

(if (< r beta-tmp) (setf beta-tmp r))))))

((nodo-max nodo)

(let ((alpha-tmp alpha))

(do ((ch (hijos nodo) (cdr ch)))

((or (null ch) (<= beta alpha-tmp)) alpha-tmp)

(let ((r (minimax-alpha-beta (car ch) alpha-tmp beta)))

(if (< alpha-tmp r) (setf alpha-tmp r))))))))

And I have an example tree implemented like this:

- Code: Select all
`(defparameter *tree-001*`

'(max ((min ((max ((min (15 14))

(min (13 12))))

(max ((min (11 10))

(min (9 8))))))

(min ((max ((min (7 6))

(min (5 4))))

(max ((min (3 2))

(min (1 0)))))))))

Where would I have to put the "reverse" so that I would do it the other way around?