Reputation: 145
I have a function that the minimax-alpha-beta does, the fact is that it reads from left to right and I would like it to read backwards and I thought about the "reverse" function but I can not get it to work for me.
The code is the following:
(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:
(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?
Upvotes: 0
Views: 315
Reputation: 51501
I guess that hijos
returns the children of each node. This might be the thing you want to reverse.
Upvotes: 2