I tried coding Alpha-beta using the pseudocode found in Wikipedia. After the program reaches (EQ depth 0)
it returns the heuristic value but depth continues deacreasing causing a cycle. Right now my code looks like this:
(defun ab(tab node depth a b)
(cond ((EQ depth 0) (calculaH tab))
((eq (mod depth 2) 0) (setq v -999999) (setq movimiento (sigMov depth node tab)) (loop while (not(null movimiento))
do (setq v (max v (ab (nth 3 movimiento) movimiento (- depth 1) a b)))
(setq a (max a v))
(cond((<= b a) (break))
(t (setq movimiento (sigMov depth movimiento tab))))) (return v))
(t (setq v 999999) (setq movimiento (sigMov depth node tab)) (loop while (not(null movimiento))
do (setq v (min v (ab (nth 3 movimiento) movimiento (- depth 1) a b)))
(setq a (min b v))
(cond((<= b a) (break))
(t (setq movimiento (sigMov depth movimiento tab))))) (return v))))
Should I increase depth value somwhere in my code? Why doesn´t the recursion increases the value by itself?