diff lisp/play/landmark.el @ 30888:e559f0aa6b2d

Don't quote lambda.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 16 Aug 2000 21:05:37 +0000
parents f03ab02d1f4e
children 294c98d5718b
line wrap: on
line diff
--- a/lisp/play/landmark.el	Wed Aug 16 21:03:36 2000 +0000
+++ b/lisp/play/landmark.el	Wed Aug 16 21:05:37 2000 +0000
@@ -60,7 +60,7 @@
 ;;; concise problem description.
 
 ;;;_* Require
-(require 'cl)
+(eval-when-compile (require 'cl))
 
 ;;;_* From Gomoku
 
@@ -1153,7 +1153,7 @@
 ;;(setq direction 'lm-n)
 ;;(get 'lm-n 'lm-s)
 (defun lm-nslify-wts-int (direction)
-  (mapcar '(lambda (target-direction)
+  (mapcar (lambda (target-direction)
 	     (get direction target-direction))
 	  lm-directions))
 
@@ -1166,7 +1166,7 @@
 		  (eval (cons 'max l)) (eval (cons 'min l))))))
 
 (defun lm-print-wts-int (direction)
-  (mapc '(lambda (target-direction)
+  (mapc (lambda (target-direction)
 	     (insert (format "%S %S %S "
 			      direction
 			      target-direction
@@ -1233,14 +1233,14 @@
     (set-buffer "*lm-blackbox*")
     (insert "==============================\n")
     (insert "I smell: ")
-    (mapc '(lambda (direction)
+    (mapc (lambda (direction)
 	       (if (> (get direction 'smell) 0)
 		   (insert (format "%S " direction))))
 	    lm-directions)
     (insert "\n")
 
     (insert "I move: ")
-    (mapc '(lambda (direction)
+    (mapc (lambda (direction)
 	       (if (> (get direction 'y_t) 0)
 		   (insert (format "%S " direction))))
 	    lm-directions)
@@ -1295,7 +1295,7 @@
 ;   (* (/ (random 900000) 900000.0) .0001)))
 ;;;_   : lm-randomize-weights-for (direction)
 (defun lm-randomize-weights-for (direction)
-  (mapc '(lambda (target-direction)
+  (mapc (lambda (target-direction)
 	     (put direction
 		  target-direction
 		  (* (lm-flip-a-coin) (/  (random 10000) 10000.0))))
@@ -1306,7 +1306,7 @@
 
 ;;;_   : lm-fix-weights-for (direction)
 (defun lm-fix-weights-for (direction)
-  (mapc '(lambda (target-direction)
+  (mapc (lambda (target-direction)
 	     (put direction
 		  target-direction
 		  lm-initial-wij))
@@ -1390,7 +1390,7 @@
 	   0.0))))
 
 (defun lm-update-normal-weights (direction)
-  (mapc '(lambda (target-direction)
+  (mapc (lambda (target-direction)
 	     (put direction target-direction
 		  (+
 		   (get direction target-direction)
@@ -1401,7 +1401,7 @@
 	  lm-directions))
 
 (defun lm-update-naught-weights (direction)
-  (mapc '(lambda (target-direction)
+  (mapc (lambda (target-direction)
 	     (put direction 'w0
 		  (lm-f
 		   (+
@@ -1415,7 +1415,7 @@
 ;;;_ + Statistics gathering and creating functions
 
 (defun lm-calc-current-smells ()
-  (mapc '(lambda (direction)
+  (mapc (lambda (direction)
 	     (put direction 'smell (calc-smell-internal direction)))
 	  lm-directions))
 
@@ -1427,7 +1427,7 @@
     (setf lm-no-payoff 0)))
 
 (defun lm-store-old-y_t ()
-  (mapc '(lambda (direction)
+  (mapc (lambda (direction)
 	     (put direction 'y_t-1 (get direction 'y_t)))
 	  lm-directions))
 
@@ -1435,35 +1435,33 @@
 ;;;_ + Functions to move robot
 
 (defun lm-confidence-for (target-direction)
-  (+
-   (get target-direction 'w0)
-   (reduce '+
-    (mapcar '(lambda (direction)
-	       (*
-		(get direction target-direction)
-		(get direction 'smell))
-			)
-	    lm-directions))))
+  (apply '+
+	 (get target-direction 'w0)
+	 (mapcar (lambda (direction)
+		   (*
+		    (get direction target-direction)
+		    (get direction 'smell)))
+		 lm-directions)))
 
 
 (defun lm-calc-confidences ()
-  (mapc '(lambda (direction)
+  (mapc (lambda (direction)
 	     (put direction 's (lm-confidence-for direction)))
 	     lm-directions))
 
 (defun lm-move ()
   (if (and (= (get 'lm-n 'y_t) 1.0) (= (get 'lm-s 'y_t) 1.0))
       (progn
-	(mapc '(lambda (dir) (put dir 'y_t 0)) lm-ns)
+	(mapc (lambda (dir) (put dir 'y_t 0)) lm-ns)
 	(if lm-debug
 	    (message "n-s normalization."))))
   (if (and (= (get 'lm-w 'y_t) 1.0) (= (get 'lm-e 'y_t) 1.0))
       (progn
-	(mapc '(lambda (dir) (put dir 'y_t 0)) lm-ew)
+	(mapc (lambda (dir) (put dir 'y_t 0)) lm-ew)
 	(if lm-debug
 	    (message "e-w normalization"))))
 
-  (mapc '(lambda (pair)
+  (mapc (lambda (pair)
 	     (if (> (get (car pair) 'y_t) 0)
 		 (funcall (car (cdr pair)))))
 	  '(
@@ -1479,7 +1477,7 @@
 
 (defun lm-random-move ()
   (mapc
-   '(lambda (direction) (put direction 'y_t 0))
+   (lambda (direction) (put direction 'y_t 0))
    lm-directions)
   (dolist (direction (nth (random 8) lm-8-directions))
     (put direction 'y_t 1.0))
@@ -1575,14 +1573,14 @@
 
   (lm-set-landmark-signal-strengths)
 
-  (mapc '(lambda (direction)
+  (mapc (lambda (direction)
 	     (put direction 'y_t 0.0))
 	  lm-directions)
 
   (if (not save-weights)
       (progn
 	(mapc 'lm-fix-weights-for lm-directions)
-	(mapc '(lambda (direction)
+	(mapc (lambda (direction)
 		   (put direction 'w0 lm-initial-w0))
 	lm-directions))
     (message "Weights preserved for this run."))
@@ -1612,10 +1610,10 @@
 
   (setq lm-tree-r       (* (sqrt (+ (square lm-cx) (square lm-cy))) 1.5))
 
-  (mapc '(lambda (direction)
+  (mapc (lambda (direction)
 	     (put direction 'r (* lm-cx 1.1)))
 	lm-ew)
-  (mapc '(lambda (direction)
+  (mapc (lambda (direction)
 	     (put direction 'r (* lm-cy 1.1)))
 	lm-ns)
   (put 'lm-tree 'r lm-tree-r))