(defun life ()
(setq all_objects '(wolf dog wall1 obstacle2))
;; here you create a list of all moving objects (animals), growing objects (plants) and non-animated objects (obstacles)
;; let us observe that the algorithm remains in principle the same for any number of any type of objects.
;; animals move, trees grow, other objects do not change their position. (adding trees and other animals is
;; optional in your homework)
(simulate all_objects)
)
(defun simulate (list_of_objects_to_simulate)
(new_list_of_objects_to_simulate (one_stage_of_life list_of_objects_to_simulate));; function one_stage_of_life
;; creates new states of objects and returns the new list of objects
;; the killed objects are removed, the new-born (as result of mating) objects are added)
;; the objects that reached their goals are removed.
(cond ((equal_states list_of_objects_to_simulate new_list_of_objects_to_simulate)
(terminate)) ;; nothing changed in the micro-world, it became static, so let us make the end of world.
(simulate new_list_of_objects_to_simulate) ;; recursive call with all old and new alive objects.
)
(defun one_stage_of_life (list-of-objects)
(mapcar list-of-objects '(move_object object)) ; one unit of time of simulation
;; all objects from the list are "moved" (i.e. trees grow, animals move, kill, eat or mate,
;; obstacles stay where they are)
;; when two animals mate, they create a random number of children immediately
;; goals of children are averaged goals of parents (in this world).
;; recall that goal is a (x,y) coordinate where the animals goes.
(display all_objects) ;; just graphics, it goes through all objects and displays them.
;; you need some simple geometry like checking if two line intervals intersect to see if you are close to obstacle.