;; D. Vrajitoru, C463/B551 Spring 2006 ;; Code for testing the reflex agent in homework 2. ;; Add the function for the reflex agent called nlife_agent for the ;; function bellow to work. ;; A function that transforms a list by replacing every element with ;; the result of the processing done by the reflex agent to be ;; written. It doesn't change the original list but returns the result ;; list instead. (defun nlife (L prev) (if (not L) nil (if (not prev) (nlife L 0) (if (eq (length L) 1) (list (nlife_agent prev (car L) 0)) (append (list (nlife_agent prev (car L) (car (cdr L)))) (nlife (cdr L) (car L))))))) ;; Creating a global list to test the function (setq testl (list 1 2 3 4)) (1 2 3 4) ;; Evaluating this expression should result in the list bellow. (nlife testl nil) (0 0 1 7) ;; Evaluating this expression repeteadly should run the game of ;; numerical life. The sequence of lists bellow is an example of the ;; evolution of the original list through this process, shown ;; backwards (it starts at the bottom going up). (setq testl (nlife testl nil)) (18 8 24 60) (1 17 49 11) (3 0 14 35) (6 0 28 70) (5 1 57 13) (0 5 26 26) (0 0 5 21) (1 0 17 4) (0 1 8 8) (0 0 1 7)