;


(defvar *system-is-still-learning*)
(defvar *style*)
(defvar *done-time*)
(defvar *block-size*)
(defvar *jtb-hacked-block-number*)
(defvar *current-focus*)
(defvar *correct-category*)
(defvar *rt*)
(defvar *last-guess*)

(defvar *ebrw-criterion*)
(defvar *lax-criterion*)
(defvar *strict-criterion*)

(defvar *r-time* .05)
(defvar *r-thresh* 0)
(defvar *intercept* .2)
(defvar *counter-thresh* 1)
(defvar *runs* 5)
(defvar *text* t)
(defvar *graphic* nil)
(defvar *v* nil)
(defvar *overlay* nil)


(defparameter *categories* '(category-a category-b))
(defparameter *egs* (/ 2.2 (sqrt 2)))
(defparameter *noise* .55)
(defparameter *jtb-sim-factor* 30)
(defparameter *jtb-hack-track* nil)
(defparameter *learning* nil)
(defparameter *styles* nil)

(defparameter *experiment-3-patterns*
  '((item1 h-nine p-two nil nil category-a) (item2 h-nine p-seven nil nil category-a)
    (item3 h-eight p-five nil nil category-a)  (item4 h-seven p-zero nil nil category-a)
    (item5 h-seven p-nine nil nil category-a) (item6 h-six p-four nil nil category-a)
    (item7 h-five p-one nil nil category-a) (item8 h-five p-six nil nil category-a)
    
    (item9-1 h-seven p-two nil nil category-c) (item9-2 h-seven p-two nil nil category-c)
    (item9-3 h-seven p-two nil nil category-c) (item9-4 h-seven p-two nil nil category-c)
    
    (item10-1 h-seven p-seven nil nil category-a)(item10-2 h-seven p-seven nil nil category-a)
    
    (item11 h-four p-three nil nil category-b) (item12 h-four p-eight nil nil category-b)
    (item14 h-three p-five nil nil category-b) (item15 h-two p-zero nil nil category-b)
    (item16 h-two p-nine nil nil category-b) (item17 h-one p-four nil nil category-b)
    (item18 h-zero p-two nil nil category-b) (item19 h-zero p-seven nil nil category-b)
    
    (item20-1 h-two p-two nil nil category-b) (item20-2 h-two p-two nil nil category-b)
    (item20-3 h-two p-two nil nil category-b) (item20-4 h-two p-two nil nil category-b)
    
    (item21-1 h-two p-seven nil nil category-d) (item21-2 h-two p-seven nil nil category-d)
    
    
    )
  )

(defparameter *experiment-3-transfer-patterns* '(
                                                 (tran0 h-zero p-zero nil nil category-b)(tran1 h-zero p-one nil nil category-b)
                                                 (tran2 h-zero p-two  nil nil category-b)(tran3 h-zero p-three nil nil category-b)
                                                 (tran4 h-zero p-four nil nil category-b)(tran5 h-zero p-five nil nil category-b)
                                                 (tran6 h-zero p-six nil nil category-b) (tran7 h-zero p-seven nil nil category-b)  
                                                 (tran8 h-zero p-eight nil nil category-b)
                                                 (tran9 h-zero p-nine nil nil category-b)   (tran10 h-one p-zero nil nil category-b)   
                                                 (tran11 h-one p-one nil nil category-b)
                                                 (tran12 h-one p-two nil nil category-b)    (tran13 h-one p-three nil nil category-b)  (tran14 h-one p-four nil nil category-b)
                                                 (tran15 h-one p-five nil nil category-b)   (tran16 h-one p-six nil nil category-b)    (tran17 h-one p-seven nil nil category-b)
                                                 (tran18 h-one p-eight nil nil category-b)  (tran19 h-one p-nine nil nil category-b)   (tran20 h-two p-zero nil nil category-b)
                                                 (tran21 h-two p-one nil nil category-b)    (tran22 h-two p-two nil nil category-b)    (tran23 h-two p-three nil nil category-b)
                                                 (tran24 h-two p-four nil nil category-b)   (tran25 h-two p-five nil nil category-b)   (tran26 h-two p-six nil nil category-b)
                                                 (tran27 h-two p-seven nil nil category-b)  (tran28 h-two p-eight nil nil category-b)  (tran29 h-two p-nine nil nil category-b)
                                                 (tran30 h-three p-zero nil nil category-b) (tran31 h-three p-one nil nil category-b)  (tran32 h-three p-two nil nil category-b)
                                                 (tran33 h-three p-three nil nil category-b)(tran34 h-three p-four nil nil category-b) (tran35 h-three p-five nil nil category-b)
                                                 (tran36 h-three p-six nil nil category-b)  (tran37 h-three p-seven nil nil category-b)(tran38 h-three p-eight nil nil category-b)
                                                 (tran39 h-three p-nine nil nil category-b) (tran40 h-four p-zero nil nil category-b)  (tran41 h-four p-one nil nil category-b)
                                                 (tran42 h-four p-two nil nil category-b)   (tran43 h-four p-three nil nil category-b) (tran44 h-four p-four nil nil category-b)
                                                 (tran45 h-four p-five nil nil category-b)  (tran46 h-four p-six nil nil category-b)   (tran47 h-four p-seven nil nil category-b)
                                                 (tran48 h-four p-eight nil nil category-b) (tran49 h-four p-nine nil nil category-b nil nil category-b)  
                                                 
                                                 (tran50 h-five p-zero nil nil category-a)
                                                 (tran51 h-five p-one nil nil category-a)   (tran52 h-five p-two nil nil category-a)   (tran53 h-five p-three nil nil category-a)
                                                 (tran54 h-five p-four nil nil category-a)  (tran55 h-five p-five nil nil category-a)  (tran56 h-five p-six nil nil category-a)
                                                 (tran57 h-five p-seven nil nil category-a) (tran58 h-five p-eight nil nil category-a) (tran59 h-five p-nine nil nil category-a)
                                                 (tran60 h-six p-zero nil nil category-a)   (tran61 h-six p-one nil nil category-a)    (tran62 h-six p-two nil nil category-a)
                                                 (tran63 h-six p-three nil nil category-a)  (tran64 h-six p-four nil nil category-a)   (tran65 h-six p-five nil nil category-a)
                                                 (tran66 h-six p-six nil nil category-a)    (tran67 h-six p-seven nil nil category-a)  (tran68 h-six p-eight nil nil category-a)
                                                 (tran69 h-six p-nine nil nil category-a)   (tran70 h-seven p-zero nil nil category-a) (tran71 h-seven p-one nil nil category-a)
                                                 (tran72 h-seven p-two nil nil category-a)(tran73 h-seven p-three nil nil category-a)(tran74 h-seven p-four nil nil category-a)
                                                 (tran75 h-seven p-five nil nil category-a) (tran76 h-seven p-six nil nil category-a)  (tran77 h-seven p-seven nil nil category-a)
                                                 (tran78 h-seven p-eight nil nil category-a)(tran79 h-seven p-nine nil nil category-a) (tran80 h-eight p-zero nil nil category-a)
                                                 (tran81 h-eight p-one nil nil category-a)  (tran82 h-eight p-two nil nil category-a)  (tran83 h-eight p-three nil nil category-a)
                                                 (tran84 h-eight p-four nil nil category-a) (tran85 h-eight p-five nil nil category-a) (tran86 h-eight p-six nil nil category-a)
                                                 (tran87 h-eight p-seven nil nil category-a)(tran88 h-eight p-eight nil nil category-a)(tran89 h-eight p-nine nil nil category-a)
                                                 (tran90 h-nine p-zero nil nil category-a)  (tran91 h-nine p-one nil nil category-a)   (tran92 h-nine p-two nil nil category-a)
                                                 (tran93 h-nine p-three nil nil category-a) (tran94 h-nine p-four nil nil category-a)  (tran95 h-nine p-five nil nil category-a)
                                                 (tran96 h-nine p-six nil nil category-a)   (tran97 h-nine p-seven nil nil category-a) (tran98 h-nine p-eight nil nil category-a)
                                                 (tran99 h-nine p-nine nil nil category-a)))


(defconstant *exp3-data-catds3* '(73 79 87 81 62.5 50.9 87.2 80.9))

(defconstant *atrium-data-catds3* '(68 76 78 76 67 49 85 82))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; This section contains the interface for the WWW using the
;;; ACT-R on the Web application by Elmar Schwarz

(setf  *WWW-interface* 
      '((:heading "Categorization Model of Erickson & Krushke, 1998" 2)
        (:table)
        
        (:table)
        "Retrieval Time: "        (:string :sy *r-time*  .05)   (:new-row)
        "Retrieval Threshold: "   (:string :sy *r-thresh*  0.0)  (:new-row)
        "Intercept Parameter: "   (:string :sy *intercept*  .20)     (:new-row)
        "Counter Threshold: "     (:string :sy *counter-thresh* 1)     (:new-row)
        "Number of runs (1-200): " (:string :sy *runs* 5)
        (:table-end)
        
        (:table)
       (:checkbox "Trace (NOT recommended, see below)" :sy *v*  nil)  (:new-row)
        (:checkbox "Text output" :sy *text*  t) (:new-row)
        (:checkbox "Graphic output" :sy *graphic*  nil) (:new-row)
        (:checkbox "Show both simulation and experiment data" :sy *overlay*  nil) 
        (:table-end)
        
        (:table-end)
         
         
         (:new-para)
         
        (:button "Show Experimental and ATRIUM Results" "(display-catds3 nil 
                                                                       *exp3-data-catds3* *atrium-data-catds3*)")
           
        (:new-para)
        
        (:button "Run model" "(if (and (numberp *r-time*) (numberp *r-thresh*)
                                       (numberp *intercept*) (numberp *counter-thresh*)
                                       (numberp *runs*))
                                   (display-catds3  (demo-3-catds3 (min 200 (max 1 *runs*)) *r-time* *r-thresh* *intercept* *counter-thresh*)
                                                     *exp3-data-catds3* *atrium-data-catds3*
                                                                       )
                                   
                                   (format *standard-output* \"All parameters must be numbers~%\"))")
        (:reset "Default values")
        (:button "Production Rules" "(let ((prods (no-output (pp))))
                                       (dolist (x prods)
                                         (pp-fct (list x))
                                         (spp-fct (list x))
                                         (format *standard-output* \"~%\")))")
        (:button "Chunk types" "(chunk-type)")
        (:button "Chunks" "(dm)")
        (:new-para)
         "TIME and SIZE:"
        (:new-para)
        "- It usually takes about 2 minutes for 5 runs of the model"
        (:new-line)
        "- The trace of 1 run is approximatly 0.6 MEGABYTES (300 pages) in size"
        (:new-para)))



(defun display-catds3 (model experi atrium)
  (when model 
    (format *standard-output* "~%~%Parameters for run: (~S ~S ~S ~S ~S)~%" 
            *r-time* *r-thresh* *intercept* *counter-thresh* (min 200 (max 1 *runs*))))
  
 
  (dotimes (i 8)
    (when model
      (setf (nth i model) (* 100 (nth i model))))
    )
    

  (when *text*
    (when model
      (format *standard-output* "~%~%ACT-R Percent \"Correct\"~%")
      (format *standard-output* "~%                        Frequency~%                       2        4~%")
      (format *standard-output* "Training Rule        ~6,1f ~6,1f~%" (nth 7 model) (nth 6 model))
      (format *standard-output* "Training Exception   ~6,1f ~6,1f~%" (nth 5 model) (nth 4 model))
      (format *standard-output* "Transfer Rule        ~6,1f ~6,1f~%" (nth 3 model) (nth 2 model))
      (format *standard-output* "Transfer Exception   ~6,1f ~6,1f~%" (nth 1 model) (nth 0 model))
      )
      
    (when (or (null model) *overlay*)
      (format *standard-output* "~%~%Experimental Percent \"Correct\"~%")
      (format *standard-output* "~%                        Frequency~%                       2        4~%")
      (format *standard-output* "Training Rule        ~6,1f ~6,1f~%" (nth 7 experi) (nth 6 experi))
      (format *standard-output* "Training Exception   ~6,1f ~6,1f~%" (nth 5 experi) (nth 4 experi))
      (format *standard-output* "Transfer Rule        ~6,1f ~6,1f~%" (nth 3 experi) (nth 2 experi))
      (format *standard-output* "Transfer Exception   ~6,1f ~6,1f~%" (nth 1 experi) (nth 0 experi))
      (format *standard-output* "~%~%ATRIUM Percent \"Correct\"~%")
      (format *standard-output* "~%                        Frequency~%                       2        4~%")
      (format *standard-output* "Training Rule        ~6,1f ~6,1f~%" (nth 7 atrium) (nth 6 atrium))
      (format *standard-output* "Training Exception   ~6,1f ~6,1f~%" (nth 5 atrium) (nth 4 atrium))
      (format *standard-output* "Transfer Rule        ~6,1f ~6,1f~%" (nth 3 atrium) (nth 2 atrium))
      (format *standard-output* "Transfer Exception   ~6,1f ~6,1f~%" (nth 1 atrium) (nth 0 atrium))
      (format *standard-output* "~%")
      )
      
      (unless *graphic* (format *standard-output* 
                                "~%</pre>If your browser supports JAVA, you 
                               can display the data in a graph by checking 
                               the Graphic output box on the interface page.<pre>~%~%")))



  (when *graphic* 
     (when model
        (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 270 
        height = 400> 
        <PARAM name=\"title\" value=\"ACT-R\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"5\">
        <PARAM name=\"ymax\" value=\"100\">
        <PARAM name=\"ymin\" value=\"30\">
        <PARAM name=\"numxlabels\" value=\"5\">
        <PARAM name=\"xlabels\" value=\" ;2; ;4; ;\">
        <PARAM name=\"widestxlabel\" value=\"W\">
        <PARAM name=\"longestline\" value=\"2\">
        <PARAM name=\"numlines\" value=\"4\">
        <PARAM name=\"yspacing\" value=\"10\">
        <PARAM name=\"ydiv\" value=\"2.5\">
        <PARAM name=\"xname\" value=\"Frequency\">
        <PARAM name=\"yname\" value=\"Percent Correct\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"0\">
        <PARAM name=\"xval0\" value=\"2;4;\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"0\">
        <PARAM name=\"xval1\" value=\"2;4;\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"0\">
        <PARAM name=\"xval2\" value=\"2;4;\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"0\">
        <PARAM name=\"xval3\" value=\"2;4;\">
        <PARAM name=\"yval0\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval1\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval2\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval3\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"name0\" value=\"Training Rule\">
        <PARAM name=\"name1\" value=\"Training Exception\">
        <PARAM name=\"name2\" value=\"Transfer Rule\">
        <PARAM name=\"name3\" value=\"Transfer Exception\">"
                (nth 7 model) (nth 6 model) (nth 5 model) (nth 4 model) 
                (nth 3 model) (nth 2 model) (nth 1 model) (nth 0 model)
                )
        
        

        )
     (when (or (null model) *overlay*) 
         (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 270 
        height = 400> 
        <PARAM name=\"title\" value=\"Experimental\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"5\">
        <PARAM name=\"ymax\" value=\"100\">
        <PARAM name=\"ymin\" value=\"30\">
        <PARAM name=\"numxlabels\" value=\"5\">
        <PARAM name=\"xlabels\" value=\" ;2; ;4; ;\">
        <PARAM name=\"widestxlabel\" value=\"W\">
        <PARAM name=\"longestline\" value=\"2\">
        <PARAM name=\"numlines\" value=\"4\">
        <PARAM name=\"yspacing\" value=\"10\">
        <PARAM name=\"ydiv\" value=\"2.5\">
        <PARAM name=\"xname\" value=\"Frequency\">
        <PARAM name=\"yname\" value=\"Percent Correct\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"0\">
        <PARAM name=\"xval0\" value=\"2;4;\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"0\">
        <PARAM name=\"xval1\" value=\"2;4;\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"0\">
        <PARAM name=\"xval2\" value=\"2;4;\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"0\">
        <PARAM name=\"xval3\" value=\"2;4;\">
        <PARAM name=\"yval0\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval1\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval2\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval3\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"name0\" value=\"Training Rule\">
        <PARAM name=\"name1\" value=\"Training Exception\">
        <PARAM name=\"name2\" value=\"Transfer Rule\">
        <PARAM name=\"name3\" value=\"Transfer Exception\">"
                (nth 7 experi) (nth 6 experi) (nth 5 experi) (nth 4 experi) 
                (nth 3 experi) (nth 2 experi) (nth 1 experi) (nth 0 experi)
                )
        
       


         (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 270 
        height = 400> 
        <PARAM name=\"title\" value=\"ATRIUM\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"5\">
        <PARAM name=\"ymax\" value=\"100\">
        <PARAM name=\"ymin\" value=\"30\">
        <PARAM name=\"numxlabels\" value=\"5\">
        <PARAM name=\"xlabels\" value=\" ;2; ;4; ;\">
        <PARAM name=\"widestxlabel\" value=\"W\">
        <PARAM name=\"longestline\" value=\"2\">
        <PARAM name=\"numlines\" value=\"4\">
        <PARAM name=\"yspacing\" value=\"10\">
        <PARAM name=\"ydiv\" value=\"2.5\">
        <PARAM name=\"xname\" value=\"Frequency\">
        <PARAM name=\"yname\" value=\"Percent Correct\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"0\">
        <PARAM name=\"xval0\" value=\"2;4;\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"0\">
        <PARAM name=\"xval1\" value=\"2;4;\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"0\">
        <PARAM name=\"xval2\" value=\"2;4;\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"0\">
        <PARAM name=\"xval3\" value=\"2;4;\">
        <PARAM name=\"yval0\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval1\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval2\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"yval3\" value=\"~4,3f;~4,3f;\">
        <PARAM name=\"name0\" value=\"Training Rule\">
        <PARAM name=\"name1\" value=\"Training Exception\">
        <PARAM name=\"name2\" value=\"Transfer Rule\">
        <PARAM name=\"name3\" value=\"Transfer Exception\">"
                (nth 7 atrium) (nth 6 atrium) (nth 5 atrium) (nth 4 atrium) 
                (nth 3 atrium) (nth 2 atrium) (nth 1 atrium) (nth 0 atrium)
                )
        
        

        )

     (format *standard-output* "
             <HR> Either your browser does not support JAVA or this graph has scrolled off the top of the display.~%
             </HR></applet>")
)
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun demo-3-catds3 (n time tau intercept counter)
  (setf *rt* tau)
  (setq *ebrw-criterion* counter)
  (setf *jtb-sim-factor*  30)
  (run-n-catds3 n time intercept))

(defun run-n-catds3 (n  time  intercept)
  (setf *learning* nil) (setf *styles* nil)
  (do ((count 0 (1+ count))
       (result (list 0 0 0 0 0 0 0 0) (do ((temp1 (run-experiment-3-once-catds3 time intercept) (cdr temp1))
                                           (temp2 result (cdr temp2))
                                           (result1 nil (cons (+ (/ (car temp1) n) (car temp2)) result1)))
                                          ((null temp1) (reverse result1)))))
      ((equal count n) result)))

(defun run-experiment-3-once-catds3 ( time intercept)
  (setf *categories* '(category-a category-b category-c category-d))
  (let (transfer-results results learning transfer (style nil))
    (reset) 
    (spp-fct (list 'done-classifying-by-exemplar :effort intercept))
    (spp-fct (list 'DONE-CLASSIFYING-BY-RULE :effort intercept))
    (spp-fct (list 'recall-2feature :effort time))
    (experiment-3-setup-catds3 *rt*)
    (sgp-fct (list :v *v* ))
    (setq *system-is-still-learning* 1)
    (setq *jtb-hacked-block-number* 1)
    (do ((n 0 (+ 1 n))) ((equal n 16))
      (setq results (append results (list (experiment-3-present-block-catds3 *experiment-3-patterns*))))
      (setf style (append style (list *style*)))
      (setq *system-is-still-learning* nil)
      (setq transfer-results (append (experiment-3-present-block-catds3 
                                      (nbutlast (randomize-catds3 *experiment-3-transfer-patterns*) 85))
                                     transfer-results))  
      
      (setq *system-is-still-learning* 1))
    
    (setf *styles* (cons style *STYLES*))
    (setf learning  (analyze-results-catds3 (apply 'append results) 
                                     '((item9-1 item9-2 item9-3 item9-4) (category-a category-b category-c category-d)) 
                                     '((item10-1 item10-2) (category-a category-b category-c category-d)) 
                                     '((item20-1 item20-2 item20-3 item20-4) (category-a category-b category-c category-d)) 
                                     '((item21-1 item21-2) (category-a category-b category-c category-d))))
    (setf *learning* (cons learning *learning*))
    (setf transfer (analyze-results-catds3 transfer-results 
                                    '((tran81 tran82 tran83 tran71 tran73 tran61 tran62 tran63)
                                      (category-a category-b category-c category-d)) 
                                    '((tran86 tran87 tran88 tran76 tran78 tran66 tran67 tran68)
                                      (category-a category-b category-c category-d)) 
                                    '((tran31 tran32 tran33 tran21 tran23 tran11 tran12 tran13)
                                      (category-a category-b category-c category-d)) 
                                    '((tran36 tran37 tran38 tran26 tran28 tran16 tran17 tran18)
                                      (category-a category-b category-c category-d)))) 
    (list
     (score-3-catds3 (first transfer) 0)
     (score-3-catds3 (fourth transfer) 1)
     (score-3-catds3 (third transfer) 1)
     (score-3-catds3 (second transfer) 0)
     (score-3-catds3 (first learning) 2) (score-3-catds3 (fourth learning) 3)
     (score-3-catds3 (third learning) 1)(score-3-catds3 (second learning)0))
    ))



(defun experiment-3-setup-catds3 (rt)
  (add-dm
   (h-zero ISA feature-value value 0)  (h-one ISA feature-value value 1)  (h-two ISA feature-value value 2)   (h-three ISA feature-value value 3)
   (h-four ISA feature-value value 4)  (h-five ISA feature-value value 5) (h-six ISA feature-value value 6)   (h-seven ISA feature-value value 7)
   (h-eight ISA feature-value value 8) (h-nine ISA feature-value value 9) 
   
   (p-zero ISA feature-value value 0)  (p-one ISA feature-value value 1)  (p-two ISA feature-value value 2)   (p-three ISA feature-value value 3)
   (p-four ISA feature-value value 4)  (p-five ISA feature-value value 5) (p-six ISA feature-value value 6)   (p-seven ISA feature-value value 7)
   (p-eight ISA feature-value value 8) (p-nine ISA feature-value value 9)
   
   (category-a ISA category opposite category-b) (category-b ISA category opposite category-a)
   (category-c ISA category opposite category-d) (category-d ISA category opposite category-c)
   
   (rule-1 ISA rule feature1 4.5 viable T type imperfect correct 0 incorrect 0)
   (rule-2 ISA rule feature1 4.5 viable T type perfect correct 0 incorrect 0)
   (rule-3 ISA rule feature1 4.5 viable T type imperfect correct 0 incorrect 0)
   (rule-4 ISA rule feature1 4.5 viable T type imperfect correct 0 incorrect 0)
   (rule-5 ISA rule feature1 4.5 viable T type imperfect correct 0 incorrect 0)
   (rule-6 ISA rule feature1 4.5 viable T type imperfect correct 0 incorrect 0)
   )
  
  (set-base-levels (h-zero 1000 -100)  (h-one  1000 -100)  (h-two  1000 -100)   (h-three  1000 -100)
                   (h-four 1000 -100)  (h-five 1000 -100) (h-six 1000 -100)   (h-seven 1000 -100)
                   (h-eight 1000 -100) (h-nine 1000 -100) 
                   
                   (p-zero 1000 -100)  (p-one 1000 -100)  (p-two 1000 -100)   (p-three 1000 -100)
                   (p-four 1000 -100)  (p-five 1000 -100) (p-six 1000 -100)   (p-seven 1000 -100)
                   (p-eight 1000 -100) (p-nine 1000 -100)
                   
                   (category-a 1000 -100) (category-b 1000 -100)
                   (category-c 1000 -100) (category-d 1000 -100)
                   
                   (rule-1 1000 -100)
                   (rule-2 1000 -100)
                   (rule-3 1000 -100)
                   (rule-4 1000 -100)
                   (rule-5 1000 -100)
                   (rule-6 1000 -100)
                   )
  (setq *block-size* 9)
  (setq *lax-criterion* 0.5)
  (setq *strict-criterion* 0.6)
  
  (setq *ebrw-criterion* 4)
  
  (set-my-similarities-1-catds3 '(h-zero h-one h-two h-three h-four h-five h-six h-seven h-eight h-nine))
  (set-my-similarities-2-catds3 '(p-zero p-one p-two p-three p-four p-five p-six p-seven p-eight p-nine))
  
  (sgp-fct (list :rt rt))
  (sgp :lf 0.5)
  (sgp :lf 0.5)
  (setf *ebrw-criterion* 1))

(defun experiment-3-present-block-catds3 (patterns)
  (let (rule-use)
    (setq *jtb-hacked-block-number* (+ 2 *jtb-hacked-block-number*))
    (mapcar #'(lambda (x) (eval `(sdp ,x :references ,*jtb-hacked-block-number*))) 
            (no-output (sdm isa stimulus)))
    (mapcar #'(lambda(x) (eval `(sdp ,x :references ,(* 2 *jtb-hacked-block-number*))))
            (no-output (sdm isa stimulus feature1 h-seven feature2 p-seven category category-a)))
    (mapcar #'(lambda(x) (eval `(sdp ,x :references ,(* 2 *jtb-hacked-block-number*))))
            (no-output (sdm isa stimulus feature1 h-two feature2 p-seven category-d)))
    (mapcar #'(lambda(x) (eval `(sdp ,x :references ,(* 4 *jtb-hacked-block-number*))))
            (no-output (sdm isa stimulus feature1 h-seven feature2 p-two category category-c)))
    (mapcar #'(lambda(x) (eval `(sdp ,x :references ,(* 4 *jtb-hacked-block-number*))))
            (no-output (sdm isa stimulus feature1 h-two feature2 p-two category category-b)))
    (let (pb-res)
      (setq pb-res '())
      
      
      
      (dolist (itm (randomize-catds3 patterns))
        (setq pb-res (cons (cons (first itm)  (experiment-3-present-pattern-catds3 (cdr itm))) pb-res)))
      
      (setq rule-use 0)
      
      (mapcar (lambda(x) (if (equal x 'rule) (setq rule-use (+ 1 rule-use))))
              (mapcar #'third pb-res))
      
      
      (sort pb-res #'string-lessp :key #'car)
      )
    ))

(defun analyze-results-catds3 (results pat1 pat2 pat3 pat4) 
  (do ((temp results (cdr temp))
       (r1 nil (cond ((member (first (car temp)) (car pat1)) 
                      (setf r1 (cons (position (second (car temp)) (cadr pat1)) r1)))
                     (t r1)))
       (r2 nil (cond ((member (first (car temp)) (car pat2)) 
                      (setf r2 (cons (position (second (car temp)) (cadr pat2)) r2)))
                     (t r2)))
       (r3 nil (cond ((member (first (car temp)) (car pat3)) 
                      (setf r3 (cons (position (second (car temp)) (cadr pat3)) r3)))
                     (t r3)))
       (r4 nil (cond ((member (first (car temp)) (car pat4)) 
                      (setf r4 (cons (position (second (car temp)) (cadr pat4)) r4)))
                     (t r4))))
      ((null temp) (list (reverse r1) (reverse r2) (reverse r3) (reverse r4)))))


(defun experiment-3-present-pattern-catds3 (pattern)
  (let (name)
    (setq name (gentemp "ITEM"))
    (if (car (no-output (sgp :v))) (print pattern))
    (add-dm-fct (list (list name 'isa 'presentation 'feature1 (first pattern) 
                            'feature2 (second pattern) 'feature3 (third pattern) 'feature4 (fourth pattern))))
    (setq *correct-category* (fifth pattern))
    (setq *current-focus* name)
    (setq *done-time* nil)
    (setq *STYLE* nil)
    (goal-focus-fct (list *current-focus*))
    (run)
    (if (null *done-time*) (setq *done-time* (actr-time)))
    (setq *jtb-hack-track* (cons 
                            (if (equal *style* 'rule) 1 
                                (if (equal *style* 'exem4) 0 0.5)) *jtb-hack-track*))
    (list *last-guess* *STYLE*)))

(defun randomize-catds3 (list)
  (let ((n (length list))
        (result nil))
    (setf list (copy-tree list))
    (dotimes (i n result)
      (let ((data (nth (random (- n i)) list)))
        (push data result)
        (setf list (delete data list))))))

(defun correct-category-catds3 (blah)
  (declare (ignore blah))
  (if (equal *done-time* nil) (setq *done-time* (actr-time)))
  (setq *last-guess* (chunk-slot-value-fct *current-focus* 'category)) 
  (if *system-is-still-learning* *correct-category* (chunk-slot-value-fct *current-focus* 'category))
  )

(defun winner-catds3 (stimulus)
  (let (numA numB numC numD) 
    (setq numA (chunk-slot-value-fct stimulus 'countA))
    (setq numB (chunk-slot-value-fct stimulus 'countB))
    (setq numC (chunk-slot-value-fct stimulus 'countC))
    (setq numD (chunk-slot-value-fct stimulus 'countD))
    (if (and (>= (- numA numB) *ebrw-criterion*)
             (>= (- numA numC) *ebrw-criterion*)
             (>= (- numA numD) *ebrw-criterion*)) 'category-A
        (if (and (>= (- numB numA) *ebrw-criterion*)
                 (>= (- numB numC) *ebrw-criterion*)
                 (>= (- numB numD) *ebrw-criterion*)) 'category-B
            (if (and (>= (- numC numA) *ebrw-criterion*)
                     (>= (- numC numB) *ebrw-criterion*)
                     (>= (- numC numD) *ebrw-criterion*)) 'category-C
                (if (and (>= (- numD numA) *ebrw-criterion*)
                         (>= (- numD numB) *ebrw-criterion*)
                         (>= (- numD numC) *ebrw-criterion*)) 'category-D))))
    )
  
  )

(defun rule-category-catds3 (rule stim)
  (if (and 
       (or (and (chunk-slot-value-fct rule 'feature1) 
                (< (chunk-slot-value-fct rule 'feature1) 
                   (chunk-slot-value-fct (chunk-slot-value-fct stim 'feature1) 'value)))
           (not (chunk-slot-value-fct rule 'feature1)))
       
       
       (or (and (chunk-slot-value-fct rule 'feature2) 
                (< (chunk-slot-value-fct rule 'feature2) 
                   (chunk-slot-value-fct (chunk-slot-value-fct stim 'feature2) 'value)))
           (not (chunk-slot-value-fct rule 'feature2)))
       
       
       (or (and (chunk-slot-value-fct rule 'feature3) 
                (< (chunk-slot-value-fct rule 'feature3) 
                   (chunk-slot-value-fct (chunk-slot-value-fct stim 'feature3) 'value)))
           (not (chunk-slot-value-fct rule 'feature3)))
       
       (or (and (chunk-slot-value-fct rule 'feature4) 
                (< (chunk-slot-value-fct rule 'feature4) 
                   (chunk-slot-value-fct (chunk-slot-value-fct stim 'feature4) 'value)))
           (not (chunk-slot-value-fct rule 'feature4))))
    
    (chunk-slot-value-fct stim 'category)
    (nth (random (1- (length *categories*))) (remove (chunk-slot-value-fct stim 'category) *categories*)))
  )

(defun random-category-catds3 ()
  (nth (random (length *categories*)) *categories*)
  )



(defun increment-category-count-catds3 (classify-goal category)
  (if (equal category 'category-A)
    (modwme-fct classify-goal 
                (list 'countA (+ 1 (chunk-slot-value-fct classify-goal 'countA))))
    (if (equal category 'category-B)
      (modwme-fct classify-goal
                  (list 'countB (+ 1 (chunk-slot-value-fct classify-goal 'countB))))
      (if (equal category 'category-C)
        (modwme-fct classify-goal
                    (list 'countC (+ 1 (chunk-slot-value-fct classify-goal 'countC))))
        (if (equal category 'category-D)
          (modwme-fct classify-goal
                      (list 'countD (+ 1 (chunk-slot-value-fct classify-goal 'countD))))))))
  )



(defun set-my-similarities-1-catds3 (chunk-list)
  ; the big assumption made here for convenience is that values can not span a range of more
  ; than 10
  (let () 
    (dolist (itm1 chunk-list)
      (dolist (itm2 chunk-list)
        (set-similarities-fct 
         (list (list itm1 itm2 
                     (- 1 (/ (* (abs (- (chunk-slot-value-fct itm1 'value) (chunk-slot-value-fct itm2 'value))) 1) *jtb-sim-factor*)))))))
    )
  )

(defun set-my-similarities-2-catds3 (chunk-list)
  ; the big assumption made here for convenience is that values can not span a range of more
  ; than 10
  (let () 
    (dolist (itm1 chunk-list)
      (dolist (itm2 chunk-list)
        (set-similarities-fct 
         (list (list itm1 itm2 
                     (- 1 (/ (* (abs (- (chunk-slot-value-fct itm1 'value) (chunk-slot-value-fct itm2 'value))) 1) (* 1 *jtb-sim-factor*))))))))
    )
  )


(defun score-3-catds3 (lis target)
  (do ((temp lis (cdr temp))
       (result 0.0 (cond ((eq (car temp) target) (1+ result)) (t result))))
      ((null temp) (/ result (length lis)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; The ACT-R model



(clear-all)
(sgp-fct (list :lt nil :pct nil :pmt nil :v nil :pm t :era t :er t :pl t :bll 0.5 :ans *noise* :egs *egs* :ga 1 :lf 1 :mp 45 :rt 0.0 :ut -20))

(chunk-type presentation feature1 feature2 feature3 feature4 category choice exn-used evaluated)
(chunk-type stimulus feature1 feature2 feature3 feature4 category)
(chunk-type feature-value value)
(chunk-type category opposite)
(chunk-type clean-up)
(chunk-type rule feature1 feature2 feature3 feature4 guess viable current type correct incorrect)
(chunk-type classify-by-rule presentation category exceptions-checked exn-used)
(chunk-type apply-rule-to-presentation rule presentation checked category)
(chunk-type classify-by-exemplar presentation category counta countb countc countd feature1 feature2 feature3 feature4)
(chunk-type exception feature1 feature2 feature3 feature4 category)
(chunk-type rule-type)
(chunk-type find-rule presentation)
(chunk-type evaluate classification-style presentation count last-result exn-used)
(chunk-type classification-style)

(add-dm
   (perfect ISA rule-type)
   (imperfect ISA rule-type)
   (conjunctive ISA rule-type)
   (rule-2 isa chunk)
   (rule ISA classification-style)
   (exemplar ISA classification-style))

(P choose-to-classify-by-rule
   =goal>
      ISA         presentation
      category    nil
   =rule>
      ISA         rule
      viable      t
==>
   =classify-by-rule-goal>
      ISA         classify-by-rule
      presentation =goal
      category    =c
      exn-used    =exn
   =goal>
      category    =c
      choice      rule
      exn-used    =exn
  !eval!          (setq *STYLE* 'RULE)
   !push!         =classify-by-rule-goal
)

(P cant-do-jack
   =goal>
      ISA         presentation
      category    nil
==>
   =goal>
      category    (!eval! (random-category-catds3))
      choice      random
)

(P random-guess-was-right
   =goal>
      ISA         presentation
      choice      random
      category    =c
   !eval!         (equal =c (correct-category-catds3 =goal))
==>
   =goal>
      evaluated   right
      choice      rule
)

(P random-guess-was-wrong
   =goal>
      ISA         presentation
      choice      random
      category    =c
   !eval!         (not (equal =c (correct-category-catds3 =goal)))
==>
   =goal>
      evaluated   wrong
      category    (!eval! (correct-category-catds3 =goal))
      choice      rule
)



(P choose-to-classify-by-exemplar-4feature
   =goal>
      ISA         presentation
      category    nil
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      choice      nil
   =recall-stimulus>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =c
==>
   =classify-by-exemplar-goal>
      ISA         classify-by-exemplar
      presentation =goal
      counta      0
      countb      0
      countc      0
      countd      0
      category    =cat
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
   =goal>
      category    =cat
      choice      exemplar
    !eval!          (setq *STYLE* 'EXEM4)
   !push!         =classify-by-exemplar-goal
)

(P choose-to-classify-by-exemplar-2feature
   =goal>
      ISA         presentation
      category    nil
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      choice      nil
   =recall-stimulus>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      category    =c
==>
   =classify-by-exemplar-goal>
      ISA         classify-by-exemplar
      presentation =goal
      counta      0
      countb      0
      countc      0
      countd      0
      category    =cat
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
   =goal>
      category    =cat
      choice      exemplar
   !eval!         (setq *STYLE* 'EXEM2)
   !push!         =classify-by-exemplar-goal
)

(P cover-for-failed-classify
   =goal>
      ISA         presentation
      category    failure
==>
   =goal>
      category    (!eval! (random-category-catds3))
)

(P general-rule-match
   =goal>
      ISA         classify-by-rule
      presentation =pres
      category   nil
   =rule>
      ISA         rule
      current     t
   =pres>
      ISA         presentation
==>
!output! =rule
   =apply-rule-goal>
      ISA         apply-rule-to-presentation
      presentation =pres
      rule        =rule
      checked     0
      category    =c
   =goal>
      category    =c
      exn-used    nil
   !push!         =apply-rule-goal
)

(P done-classifying-by-rule
   =goal>
      ISA         classify-by-rule
      category    =c
    - category    failure
==>
   !pop!
)

(P feature1-with-rule
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     0
      category    nil
   =rule>
      ISA         rule
      feature1    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature1    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     1
      category    =cat
)

(P feature2-with-rule-v1
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     1
      category    nil
   =rule>
      ISA         rule
      feature2    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature2    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     2
      category    =cat
)

(P feature2-with-rule-v2
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     1
      category    =cat
   =rule>
      ISA         rule
      feature2    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature2    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     2
      category    =cat
)

(P feature3-with-rule-v1
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     2
      category    nil
   =rule>
      ISA         rule
      feature3    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature3    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     3
      category    =cat
)

(P feature3-with-rule-v2
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     2
      category    =cat
   =rule>
      ISA         rule
      feature3    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature3    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     3
      category    =cat
)

(P feature4-with-rule-v1
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     3
      category    nil
   =rule>
      ISA         rule
      feature4    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature4    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     4
      category    =cat
)

(P feature4-with-rule-v2
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     3
      category    =cat
   =rule>
      ISA         rule
      feature4    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature4    =actual
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (< =cutoff =val)
==>
   =goal>
      checked     4
      category    =cat
)

(P feature1-against-rule
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     0
      category    nil
   =rule>
      ISA         rule
      feature1    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature1    =actual
   =cat>
      ISA         category
      opposite    =opp
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (> =cutoff =val)
==>
   =goal>
      checked     1
      category    =opp
)

(P feature2-against-rule-v1
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     1
   =rule>
      ISA         rule
      feature2    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature2    =actual
   =cat>
      ISA         category
      opposite    =opp
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (> =cutoff =val)
==>
   =goal>
      checked     2
      category    =opp
)

(P feature2-against-rule-v2
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     1
      category    =cat
   =rule>
      ISA         rule
      feature2    =cutoff
    - guess       =cat
==>
   =goal>
      checked     2
)

(P feature3-against-rule-v1
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     2
   =rule>
      ISA         rule
      feature3    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature3    =actual
   =cat>
      ISA         category
      opposite    =opp
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (> =cutoff =val)
==>
   =goal>
      checked     3
      category    =opp
)

(P feature3-against-rule-v2
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     2
      category    =cat
   =rule>
      ISA         rule
      feature3    =cutoff
    - guess       =cat
==>
   =goal>
      checked     3
)

(P feature4-against-rule-v1
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     3
   =rule>
      ISA         rule
      feature4    =cutoff
      guess       =cat
   =pres>
      ISA         presentation
      feature4    =actual
   =cat>
      ISA         category
      opposite    =opp
   =actual>
      ISA         feature-value
      value       =val
   !eval!         (> =cutoff =val)
==>
   =goal>
      checked     4
      category    =opp
)

(P feature4-against-rule-v2
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      presentation =pres
      checked     3
      category    =cat
   =rule>
      ISA         rule
      feature4    =cutoff
    - guess       =cat
==>
   =goal>
      checked     4
)

(P feature1-is-nil
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      checked     0
   =rule>
      ISA         rule
      feature1    nil
==>
   =goal>
      checked     1
)

(P feature2-is-nil
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      checked     1
   =rule>
      ISA         rule
      feature2    nil
==>
   =goal>
      checked     2
)

(P feature3-is-nil
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      checked     2
   =rule>
      ISA         rule
      feature3    nil
==>
   =goal>
      checked     3
)

(P feature4-is-nil
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      checked     3
   =rule>
      ISA         rule
      feature4    nil
==>
   =goal>
      checked     4
)

(P done-applying-presentation
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      checked     4
==>
   !pop!
)

(P move-on-with-rule
   =goal>
      ISA         apply-rule-to-presentation
      rule        =rule
      checked     =n
!eval! (< =n 4)
==>
   =goal>
      checked (!eval! (1+ =n))
)

(P wild-flaming-leap-of-faith-guess
   =goal>
      ISA         classify-by-rule
      presentation =pres
==>
   =goal>
      category    (!eval! (random-category-catds3))
      exn-used    wildleapoffaith
   !pop!
)

(P check-for-exception-4
   =goal>
      ISA         classify-by-rule
      presentation =pres
   =pres>
      isa presentation
      feature1 =f1
      feature2 =f2
      feature3 =f3
      feature4 =f4
   =exception>
      isa exception
      feature1 =f1
      feature2 =f2
      feature3 =f3
      feature4 =f4
      category =c
==>
   =goal>
      category    =c
!pop!
)


(P check-for-exception-2
   =goal>
      ISA         classify-by-rule
      presentation =pres
   =pres>
      isa presentation
      feature1 =f1
      feature2 =f2
   =exception>
      isa exception
      feature1 =f1
      feature1 =f3
      feature2 =f2
      feature2 =f4
      category =c
   !eval! (and (equal =f1 =f3) (equal =f2 =f4))
==>
   =goal>
      category    =c
!pop!
)

(P recall-4feature
   =goal>
      ISA         classify-by-exemplar
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    nil
   =recall-stim>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =cat
==>
   !eval!         (increment-category-count-catds3 =goal =cat)
   =goal>
      category    (!eval! (winner-catds3 =goal))
   !output!       ("I recall ~s" =recall-stim)
)

(P recall-continue-a
   =goal>
      isa classify-by-exemplar
==>
   !eval!         (increment-category-count-catds3 =goal 'category-a)
   =goal>
      category    (!eval! (winner-catds3 =goal))
)

(P recall-continue-b
   =goal>
      isa classify-by-exemplar
==>
   !eval!         (increment-category-count-catds3 =goal 'category-b)
   =goal>
      category    (!eval! (winner-catds3 =goal))
)


(P recall-2feature
   =goal>
      ISA         classify-by-exemplar
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      category    nil
      counta      =a
   =recall-stim>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      category    =cat
==>
   !eval!         (increment-category-count-catds3 =goal =cat)
   =goal>
      category    (!eval! (winner-catds3 =goal))
   !output!       ("I recall ~s" =recall-stim)
)

(P done-classifying-by-exemplar
   =goal>
      ISA         classify-by-exemplar
      category    =cat
==>
   !pop!
)

(P correct-finish-from-exemplar
   =goal>
      ISA         presentation
      category    =c
    - category    failure
      choice      exemplar
      evaluated   nil
   !eval!         (equal =c (correct-category-catds3 =goal))
==>
   =goal>
      evaluated   right
      choice      rule
)

(P incorrect-finish-by-exemplar
   =goal>
      ISA         presentation
      category    =c
    - category    failure
      choice      exemplar
      evaluated   nil
   !eval!         (not (equal =c (correct-category-catds3 =goal)))
==>
   =goal>
      evaluated   wrong
      category    (!eval! (correct-category-catds3 =goal))
   =evaluate-goal>
      ISA         evaluate
      classification-style exemplar
      last-result wrong
      presentation =goal
      count       0
   !push!         =evaluate-goal
)


(P classification-by-rule-is-right
   =goal>
      ISA         presentation
      category    =c
      choice      rule
      exn-used    nil
      evaluated   nil
   !eval!         (equal =c (correct-category-catds3 =goal))
==>
   =goal>
      evaluated   right
   =evaluate-goal>
      ISA         evaluate
      classification-style rule
      last-result right
      presentation =goal
   !push!         =evaluate-goal
)

(P classification-by-rule-is-wrong
   =goal>
      ISA         presentation
      category    =c
    - category    failure
      choice      rule
      exn-used    nil
      evaluated   nil
   !eval!         (not (equal =c (correct-category-catds3 =goal)))
==>
   =goal>
      category    (!eval! (correct-category-catds3 =goal))
      evaluated   wrong
   =evaluate-goal>
      ISA         evaluate
      classification-style rule
      presentation =goal
      last-result wrong
   !push!         =evaluate-goal
)

(P it-was-a-wild-leap-of-faith-so-find-a-rule
   =goal>
      ISA         presentation
      category    =c
      choice      rule
      exn-used    wildleapoffaith
      evaluated   nil
==>
   =goal>
      category    (!eval! (correct-category-catds3 =goal))
      evaluated   wrong
   =newgoal>
      isa clean-up
   =find-rule-goal>
      ISA         find-rule
      presentation =goal
   !push!         =find-rule-goal
   !push!         =newgoal
)

(P it-was-a-wild-leap-of-faith-so-update-rule
   =goal>
      ISA         presentation
      category    =c
      choice      rule
      exn-used    wildleapoffaith
      evaluated   nil
   =rule>
      ISA         rule
      current     t
==>
   =goal>
      category    (!eval! (correct-category-catds3 =goal))
      evaluated   wrong)

(p nothing-to-clean-up
   =goal>
      isa clean-up
==>
!pop!)


(P one-more-study-2feature-version
   =goal>
      ISA         presentation
    - evaluated   nil
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      category    =c
      choice      rule
   !eval!         *system-is-still-learning*
==>
   =goal>
      choice      done
   =stimulus-goal>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      category    =c
   !push!         =stimulus-goal
)

(P one-more-study-4feature-version
   =goal>
      ISA         presentation
    - evaluated   nil
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =c
      choice      rule
   !eval!         *system-is-still-learning*
==>
   =goal>
      choice      done
   =stimulus-goal>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =c
   !push!         =stimulus-goal
)

(P cant-study
   =goal>
      ISA         presentation
    - evaluated   nil
      choice      rule
   !eval!         (not *system-is-still-learning*)
==>
   =goal>
      choice      done
)

(P done-wrong
   =goal>
      ISA         presentation
    - choice      rule
      evaluated   wrong
==>
   !pop!
)

(P done-right
   =goal>
      ISA         presentation
    - choice      rule
      evaluated   right
==>
   !pop!
)

(P set-study-goal-4feature
   =goal>
      ISA         evaluate
      classification-style exemplar
    - count       5
      count       =count
      presentation =pres
   =pres>
      ISA         presentation
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =c
   !eval!         *system-is-still-learning*
==>
   =goal>
      count       (!eval! (+ 1 =count))
   =study-stimulus>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =c
   !push!         =study-stimulus
)

(P set-study-goal-2feature
   =goal>
      ISA         evaluate
      classification-style exemplar
    - count       5
      count       =count
      presentation =pres
   =pres>
      ISA         presentation
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      category    =c
   !eval!         *system-is-still-learning*
==>
   =goal>
      count       (!eval! (+ 1 =count))
   =study-stimulus>
      ISA         stimulus
      feature1    =f1
      feature2    =f2
      feature3    nil
      feature4    nil
      category    =c
   !push!         =study-stimulus
)

(P pop-on-study
   =goal>
      ISA         stimulus
==>
   !pop!
)

(P done-studying
   =goal>
      ISA         evaluate
      classification-style exemplar
      count       5
==>
   !pop!
)

(P no-more-learning
   =goal>
      ISA         evaluate
   !eval!         (not *system-is-still-learning*)
==>
   !pop!
)

(P perfect-rule-is-okay
   =goal>
      ISA         evaluate
      last-result right
   =rule>
      ISA         rule
      current     t
      type        perfect
   !eval!         *system-is-still-learning*
==>
   !pop!
)

(P throw-out-perfect-rule
   =goal>
      ISA         evaluate
      classification-style rule
      last-result wrong
      presentation =pres
   =rule>
      ISA         rule
      current     t
      type        perfect
      viable      t
   !eval!         *system-is-still-learning*
==>
   =rule>
      current     nil
      viable      nil
   =find-rule-goal>
      ISA         find-rule
      presentation =pres
   !focus-on!     =find-rule-goal
)

(P increment-incorrect-count
   =goal>
      ISA         evaluate
      classification-style rule
      last-result wrong
   =rule>
      ISA         rule
      current     t
    - type        perfect
      incorrect   =ic
   !eval!         *system-is-still-learning*
==>
   =rule>
      incorrect   (!eval! (+ 1 =ic))
   =goal>
      last-result nil
)

(P increment-correct-count
   =goal>
      ISA         evaluate
      classification-style rule
      last-result right
   =rule>
      ISA         rule
      current     t
    - type        perfect
      correct     =c
   !eval!         *system-is-still-learning*
==>
   =rule>
      correct     (!eval! (+ 1 =c))
   =goal>
      last-result nil
)

(P learn-exception-to-imperfect-rule-4
   =goal>
      ISA         evaluate
      classification-style rule
      last-result wrong
      presentation =pres
      exn-used    nil
   =rule>
      ISA         rule
      correct     =c
      incorrect   =ic
      type        imperfect
      current     t
   !eval!         (>= (+ =c =ic) (* 2 *block-size*))
   !eval!         (>= (/ =c (+ =c =ic)) *strict-criterion*)
   !eval!         *system-is-still-learning*
   =pres>
      ISA         presentation
      category    =cat
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
==>
   =goal>
      exn-used t
   =exception-goal>
      ISA         exception
      feature1    =f1
      feature2    =f2
      feature3    =f3
      feature4    =f4
      category    =cat
   !focus-on!     =exception-goal
)

(P learn-exception-to-imperfect-rule-2
   =goal>
      ISA         evaluate
      classification-style rule
      last-result wrong
      presentation =pres
      exn-used    nil
   =rule>
      ISA         rule
      correct     =c
      incorrect   =ic
      type        imperfect
      current     t
   !eval!         (>= (+ =c =ic) (* 2 *block-size*))
   !eval!         (>= (/ =c (+ =c =ic)) *strict-criterion*)
   !eval!         *system-is-still-learning*
   =pres>
      ISA         presentation
      category    =cat
      feature1    =f1
      feature2    =f2
==>
   =goal>
      exn-used t
   =exception-goal>
      ISA         exception
      feature1    =f1
      feature2    =f2
      category    =cat
   !focus-on!     =exception-goal
)

(p pop-exception
   =goal>
     isa exception
==>
!pop!)

(P imperfect-rule-not-yet-to-lower-window
   =goal>
      ISA         evaluate
      classification-style rule
      last-result nil
   =rule>
      ISA         rule
      current     t
      correct     =c
      incorrect   =ic
   !eval!         (< (+ =c =ic) *block-size*)
   !eval!         *system-is-still-learning*
==>
   !pop!
)

(P keep-rule-at-lower-window
   =goal>
      ISA         evaluate
      classification-style rule
      last-result nil
   =rule>
      ISA         rule
      correct     =c
      incorrect   =ic
    - type        perfect
      current     t
   !eval!         (>= (+ =c =ic) *block-size*)
   !eval!         (< (+ =c =ic) (* 2 *block-size*))
   !eval!         (>= (/ =c (+ =c =ic)) *lax-criterion*)
   !eval!         *system-is-still-learning*
==>
   !pop!
)

(P drop-rule-at-lower-window
   =goal>
      ISA         evaluate
      classification-style rule
      last-result nil
      presentation =pres
   =rule>
      ISA         rule
      correct     =c
      incorrect   =ic
    - type        perfect
      current     t
   !eval!         (>= (+ =c =ic) *block-size*)
   !eval!         (< (+ =c =ic) (* 2 *block-size*))
   !eval!         (< (/ =c (+ =c =ic)) *lax-criterion*)
   !eval!         *system-is-still-learning*
==>
   =rule>
      current     nil
      viable      nil
   =find-rule-goal>
      ISA         find-rule
      presentation =pres
   !focus-on!     =find-rule-goal
)

(P keep-imperfect-rule-at-upper-window
   =goal>
      ISA         evaluate
      classification-style rule
      last-result nil
      presentation =pres
   =rule>
      ISA         rule
      correct     =c
      incorrect   =ic
      type        imperfect
      current     t
   !eval!         (>= (+ =c =ic) (* 2 *block-size*))
   !eval!         (>= (/ =c (+ =c =ic)) *strict-criterion*)
   !eval!         *system-is-still-learning*
==>
   !pop!
)


(P drop-imperfect-rule-at-uwindow
   =goal>
      ISA         evaluate
      classification-style rule
      last-result nil
      presentation =pres
   =rule>
      ISA         rule
      correct     =c
      incorrect   =ic
      type        imperfect
      current     t
   !eval!         (= (+ =c =ic) (* 2 *block-size*))
   !eval!         (< (/ =c (+ =c =ic)) *strict-criterion*)
   !eval!         *system-is-still-learning*
==>
   =rule>
      current     nil
      viable      nil
   =find-rule-goal>
      ISA         find-rule
      presentation =pres
   !focus-on!     =find-rule-goal
)





(P select-perfect-rule
   =goal>
      ISA         find-rule
      presentation =pres
   =rule>
      ISA         rule
      viable      t
      current     nil
      type        perfect
   =pres>
      ISA         presentation
   !eval!         *system-is-still-learning*
==>
   =rule>
      current     t
      guess       (!eval! (rule-category-catds3 =rule =pres))
   !pop!
)

(P select-imperfect-rule
   =goal>
      ISA         find-rule
      presentation =pres
   =rule>
      ISA         rule
      viable      t
      current     nil
      type        imperfect
   =pres>
      ISA         presentation
   !eval!         *system-is-still-learning*
==>
   =rule>
      current     t
      guess       (!eval! (rule-category-catds3 =rule =pres))
      correct     1
   !pop!
)




(spp SELECT-PERFECT-RULE :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp SELECT-IMPERFECT-RULE :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 750 :EVENTUAL-FAILURES 250 :EVENTUAL-EFFORTS 1000)
(spp SET-STUDY-GOAL-4FEATURE :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp SET-STUDY-GOAL-2FEATURE :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp NO-MORE-LEARNING :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp RECALL-4FEATURE :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp RECALL-2FEATURE :STRENGTH 10 :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp DONE-CLASSIFYING-BY-EXEMPLAR :EFFORT 0.20 :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp WILD-FLAMING-LEAP-OF-FAITH-GUESS  :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 250 :EVENTUAL-FAILURES 750 :EVENTUAL-EFFORTS 1000)
(spp GENERAL-RULE-MATCH :SUCCESSES 10000 :FAILURES 0 :EFFORTS 500 :EVENTUAL-SUCCESSES 8000 :EVENTUAL-FAILURES 2000 :EVENTUAL-EFFORTS 10000)
(spp DONE-CLASSIFYING-BY-RULE :EFFORT 0.20 :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp POP-ON-STUDY :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp keep-imperfect-rule-at-upper-window :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 500 :EVENTUAL-FAILURES 500 :EVENTUAL-EFFORTS 1000)
(spp recall-continue-a :SUCCESSES 10000 :FAILURES 0 :EFFORTS 500 :EVENTUAL-SUCCESSES 2500 :EVENTUAL-FAILURES 7500 :EVENTUAL-EFFORTS 10000)
(spp recall-continue-b :SUCCESSES 10000 :FAILURES 0 :EFFORTS 500 :EVENTUAL-SUCCESSES 2500 :EVENTUAL-FAILURES 7500 :EVENTUAL-EFFORTS 10000)
(spp increment-incorrect-count :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 750 :EVENTUAL-FAILURES 250 :EVENTUAL-EFFORTS 1000)
(spp increment-correct-count :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 750 :EVENTUAL-FAILURES 250 :EVENTUAL-EFFORTS 1000)
(spp learn-exception-to-imperfect-rule-2 :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp learn-exception-to-imperfect-rule-4 :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp pop-exception :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp check-for-exception-2 :SUCCESSES 1000000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp check-for-exception-4 :SUCCESSES 1000000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp RANDOM-GUESS-WAS-RIGHT :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp ONE-MORE-STUDY-4FEATURE-VERSION :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp ONE-MORE-STUDY-2FEATURE-VERSION :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp IT-WAS-A-WILD-LEAP-OF-FAITH-SO-FIND-A-RULE :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 500 :eventual-failures 500 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp it-was-a-wild-leap-of-faith-so-update-rule :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)

(spp INCORRECT-FINISH-BY-EXEMPLAR :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp DONE-RIGHT :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp COVER-FOR-FAILED-CLASSIFY :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp CORRECT-FINISH-FROM-EXEMPLAR :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp CLASSIFICATION-BY-RULE-IS-WRONG :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp CLASSIFICATION-BY-RULE-IS-RIGHT :SUCCESSES 1000 :FAILURES 0 :EFFORTS 50 :EVENTUAL-SUCCESSES 1000 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 1000)
(spp CHOOSE-TO-CLASSIFY-BY-RULE :SUCCESSES 20 :FAILURES 0 :EFFORTS 1 :EVENTUAL-SUCCESSES 30 :EVENTUAL-EFFORTS 30)
(spp CHOOSE-TO-CLASSIFY-BY-EXEMPLAR-4FEATURE :SUCCESSES 2400 :EFFORTS 120 :EVENTUAL-SUCCESSES 30 :EVENTUAL-FAILURES 50 :EVENTUAL-EFFORTS 80)
(spp DONE-WRONG :EVENTUAL-EFFORTS 1000 :EVENTUAL-FAILURES 0 :EFFORTS 50 :SUCCESSES 1000 :EVENTUAL-SUCCESSES 1000 :FAILURE T)
(spp CHOOSE-TO-CLASSIFY-BY-EXEMPLAR-2FEATURE :EFFORT 0.1  :FAILURES 0 :SUCCESSES 2400 :EFFORTS 120 :EVENTUAL-SUCCESSES 30 :EVENTUAL-FAILURES 50 :EVENTUAL-EFFORTS 80)
(spp CANT-DO-JACK :SUCCESSES 10000 :EFFORTS 500 :EVENTUAL-SUCCESSES 12500 :EVENTUAL-FAILURES 87500 :EVENTUAL-EFFORTS 100000)

(spp FEATURE1-AGAINST-RULE :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE1-WITH-RULE :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE1-IS-NIL :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)

(spp FEATURE2-AGAINST-RULE-V1 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE2-AGAINST-RULE-V2 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE2-WITH-RULE-V1 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE2-WITH-RULE-V2 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE2-IS-NIL :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp move-on-with-rule :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 300 :EVENTUAL-EFFORTS 400)
(spp FEATURE3-AGAINST-RULE-V1 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE3-AGAINST-RULE-V2 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE3-WITH-RULE-V1 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE3-WITH-RULE-V2 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE3-IS-NIL :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)

(spp FEATURE4-AGAINST-RULE-V1 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE4-AGAINST-RULE-V2 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE4-WITH-RULE-V1 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE4-WITH-RULE-V2 :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)
(spp FEATURE4-IS-NIL :EFFORT 0.05 :SUCCESSES 100 :EFFORTS 5 :EVENTUAL-SUCCESSES 100 :EVENTUAL-FAILURES 0 :EVENTUAL-EFFORTS 100)