(defun find_path(row col cnt) ;This function finds the path to the door ;check if the door is nearby (find_door row col cnt) ;If the door is not nearby go through the available path (cond (( EQ found '0) (cond ((EQ (aref labyrinth row col) '=) 1 (print "found")) ((cond((> (- col 1) -1) (cond((EQ (aref labyrinth row (- col 1)) '-) (setf (aref labyrinth row col) cnt) (setf (aref labyrinth row (- col 1)) '>) (setq cnt (+ cnt 1)) (setq col (- col 1)) (find_path row col cnt)) )) )) ((cond((< (+ row 1) 10) (cond((EQ (aref labyrinth (+ row 1) col) '-) (setf (aref labyrinth row col) cnt) (setf (aref labyrinth (+ row 1) col) '>) (setq cnt (+ cnt 1)) (setq row (+ row 1)) (find_path row col cnt)) )) )) ((cond((> (- row 1) -1) (cond((EQ (aref labyrinth (- row 1) col) '-) (setf (aref labyrinth row col) cnt) (setf (aref labyrinth (- row 1) col) '>) (setq cnt (+ cnt 1)) (setq row (- row 1)) (find_path row col cnt)) )) )) ((cond((< (+ col 1) 10) (cond((EQ (aref labyrinth row (+ col 1)) '-) (setf (aref labyrinth row col) cnt) (setf (aref labyrinth row (+ col 1)) '>) (setq cnt (+ cnt 1)) (setq col (+ col 1)) (find_path row col cnt)) )) )) (T (find_door row col cnt) (cond( (EQ found '0) (setq my_list (find_smallest row col cnt)) (setq row (car my_list)) (setq col (cadr my_list)) (setq cnt (cddr my_list)) (find_path row col cnt)) (( EQ found '1) (print "Door found")) )) ) ) (( EQ found 1) (print "Door Found")) ) )