Page 1 of 1

### Use of "reverse" Function in Lisp for minimax-alpha-beta

Posted: Sat Nov 03, 2018 6:20 am
I have a function that the minimax-alpha-beta performs, 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:

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?

### Re: Use of "reverse" Function in Lisp for minimax-alpha-beta

Posted: Tue Nov 06, 2018 9:34 am
I'm afraid that I'm struggling a little with following the logic here due to the missing DEFUNs and the Spanish(?) identifiers, but if I'm reading it correctly, you could call REVERSE on the result of HIJOS (which I assume means children?)