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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;         ACT-R 4.0 Model of Strategy Transitions in the
;;;                        Tower of Hanoi
;;;                        Version - FINAL
;;;                 Friday, March 8, 2002, 12:00 PM
;;;
;;;(c) 2001-2, Glenn Gunzelmann
;;;
;;;     Requirements:
;;;
;;; 1. A current version of Lisp
;;; 2. ACT-R 4.0 with the Scripting Extension
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;                    Running the Model:
;;;
;;; 1. Open your Lisp application
;;; 2. Load ACT-R 4.0
;;; 2. Load the Scripting Extension
;;; 3. Load this file
;;; 4. Call (run-both n)
;;;    -Where n is the number of participants
;;;    -For accurate predictions, make n >= 200
;;;    -The data are noisy, particularly for Experiment 1
;;;       -That is why data were averaged over several trials in the paper
;;;       -The output here is not averaged over trials
;;;
;;; * To save Final Path data to a file, define the variable *path*
;;;    -Should be in the form (setf *path* "Drive:Directory")
;;;    -This will create 6 files when run-both is called, one for each
;;;     of the conditions in each of the experiments
;;;      -Some additional analysis is needed, but the data contained
;;;       in those files are sufficient for generating the model
;;;       predictions for individual differences and the backward
;;;       learning curves.
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Global variables used in the simulation
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; These are just to avoid startup compiler warnings
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defparameter lftpeg nil)

(defparameter midpeg nil)

(defparameter ritpeg nil)

(defparameter *states* nil)

(defparameter disk nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Parameters for the model - Can be set if running online
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defparameter *noise* 1)

(defparameter *history* 2)

(defparameter *random-history* 200)

(defparameter *scale* .75)

(defparameter *move-time* 4)

(defvar *runs* 1)

(defvar *graphic* nil)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; These hold pieces of data from the simulation
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defparameter *path* nil)

(defparameter *flatstates* 0)

(defparameter *moves* 0)

(defparameter *finalpath* 0)

(defparameter *fpathstart* 5)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Empirical Data
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Overall average times for Experiment 1
(defparameter *TimeData1* '(146.39 76.74 52.39 47.48 35.78 39.39 32.16 24.51 31.02 30.34 22.25 24.44))

;; Overall average moves for Experiment 1
(defparameter *MovesData1* '(11.96 11.25 10.13 8.75 7.88 8.33 7.04 6.71 7.25 7.42 6.54 6.63))

;; Order is: HH, HE, EH, EE conditions - Sets of 6 problems (Hard and Easy)
(defparameter *MovesData1b* '(11.83 10.50 11.83 8.92 9.50 8.83 7.17  5.33 10.00 5.50 7.17 6.50
                              11.83 10.50 11.83 8.92 9.50 8.83 6.00  6.83  6.33 9.33 6.33 7.83
                              12.08 12.00  8.42 8.58 6.25 7.83 9.83  8.33  6.50 9.83 7.50 7.00
                              12.08 12.00  8.42 8.58 6.25 7.83 5.17  6.33  6.17 5.00 5.17 5.17))

;; 5-move, then 6-move final paths
(defparameter *fp-Data1* '(0.420 0.625 0.667 0.750 0.667 0.750 0.750 0.833 0.750 0.958 0.792 0.875
                           0.250 0.292 0.250 0.208 0.292 0.167 0.250 0.125 0.167 0.000 0.167 0.125))

;; Order is: 5-move final paths for problems 1-12 and then 6-move final paths for problems 1-12
;;           -This is on each line; each line is one condition (hh, he, eh, ee)
(defparameter *fp-E1* '(0.50 0.75 0.67 0.67 0.67 0.75 1.00 0.83 0.83 1.00 0.67 0.83 0.17 0.25 0.33 0.25 0.33 0.08 0.00 0.00 0.00 0.00 0.17 0.17
                        0.50 0.75 0.67 0.67 0.67 0.75 0.50 0.83 0.67 0.83 0.83 1.00 0.17 0.25 0.33 0.25 0.33 0.08 0.50 0.17 0.33 0.00 0.17 0.00
                        0.33 0.50 0.67 0.83 0.67 0.75 0.67 0.83 0.83 1.00 0.83 0.83 0.33 0.33 0.17 0.17 0.25 0.25 0.33 0.17 0.00 0.00 0.17 0.17
                        0.33 0.50 0.67 0.83 0.67 0.75 0.83 0.83 0.67 1.00 0.83 0.83 0.33 0.33 0.17 0.17 0.25 0.25 0.17 0.17 0.33 0.00 0.17 0.17))

;; Overall average times for Experiment 2
(defparameter *TimeData2* '(149.37 57.03 54.15 39.77 32.92 28.74 27.32 22.86 23.78 20.32 18.68 18.11 43.78 31.79 31.17 30.18 23.64 27.04))

;; Overall average moves for Experiment 2
(defparameter *MovesData2* '(15.03 10.20 10.62 8.52 8.18 8.02 8.05 7.00 7.40 7.17 6.43 6.18 9.98 9.22 9.55 9.72 8.05 9.12))

;; Data for participants in hard training condition, then easy
(defparameter *MovesData2b* '(13.43 11.17 12.14 8.90 7.87 8.30 9.27 7.17 8.50 8.30 6.73 6.63  9.33 9.27 9.80  8.80 8.27 9.27
                              16.63  9.23  9.10 8.13 8.50 7.73 6.83 6.83 6.30 6.03 6.13 5.73 10.63 9.17 9.30 10.63 7.83 8.97))

;; 5-move, then 6-move final paths
(defparameter *Fp-train-Data2* '(0.500 0.600 0.733 0.750 0.817 0.800 0.717 0.783 0.783 0.800 0.867 0.733
                                 0.283 0.267 0.217 0.233 0.167 0.150 0.200 0.183 0.167 0.167 0.100 0.200))

;; 7-move, then 8-move, then 9-move final paths
(defparameter *Fp-trans-Data2* '(0.500 0.550 0.600 0.683 0.667 0.583
                                 0.133 0.133 0.167 0.117 0.217 0.233
                                 0.250 0.200 0.150 0.100 0.067 0.050))

;; Order is: 5-move final paths for problems 1-12, then 6-move final paths for problems 1-12
;;            then 7-move, then 8-move, then 9-move final paths for the transfer problems
;;           -Top line is training on hard problems, bottom line is training on easy problems
(defparameter *fp-E2* '(0.40 0.57 0.73 0.73 0.77 0.83 0.70 0.80 0.87 0.83 0.90 0.73 0.30 0.23 0.20 0.27 0.20 0.07 0.20 0.13 0.07 0.13 0.07 0.20 0.60 0.53 0.53 0.77 0.67 0.63 0.17 0.17 0.23 0.07 0.17 0.23 0.17 0.17 0.13 0.07 0.10 0.03
                        0.60 0.63 0.73 0.77 0.87 0.77 0.73 0.77 0.70 0.77 0.83 0.73 0.27 0.30 0.23 0.20 0.13 0.23 0.20 0.23 0.27 0.20 0.13 0.20 0.40 0.57 0.67 0.60 0.67 0.53 0.13 0.10 0.10 0.17 0.27 0.23 0.33 0.23 0.17 0.13 0.03 0.07))

;;Data structure for holding problem space information about the task
;;-Used to simplify the actual model
(defun setstates ()
 (setq lftpeg (get-slot-value (get-safe-wme 'a) 'name))
 (setq midpeg (get-slot-value (get-safe-wme 'b) 'name))
 (setq ritpeg (get-slot-value (get-safe-wme 'c) 'name))
 (setf *states* (list (cons (list lftpeg lftpeg lftpeg) (list (list '(5 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;moves to goal state and goal state
                                                            (list '(4 0) (list (list midpeg midpeg ritpeg) (list lftpeg lftpeg lftpeg)))     ;moves to place large disk and state
                                                            (list '(2 0) (list (list ritpeg midpeg lftpeg) (list lftpeg lftpeg lftpeg)))))   ;moves to place medium disk and state
                    (cons (list midpeg lftpeg lftpeg) (list (list '(5 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(4 0) (list (list midpeg midpeg ritpeg) (list midpeg lftpeg lftpeg)))
                                                            (list '(2 1) (list (list ritpeg midpeg lftpeg) (list ritpeg lftpeg lftpeg)))))
                    (cons (list ritpeg lftpeg lftpeg) (list (list '(4 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(3 1) (list (list midpeg midpeg ritpeg) (list midpeg lftpeg lftpeg)))
                                                            (list '(1 0) (list (list ritpeg midpeg lftpeg) (list ritpeg lftpeg lftpeg)))))
                    (cons (list lftpeg midpeg lftpeg) (list (list '(3 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(2 0) (list (list midpeg midpeg ritpeg) (list lftpeg midpeg lftpeg)))
                                                            (list '(0 -1) (list (list lftpeg midpeg lftpeg) nil))))
                    (cons (list midpeg midpeg lftpeg) (list (list '(2 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(1 0) (list (list midpeg midpeg ritpeg) (list midpeg midpeg lftpeg)))
                                                            (list '(0 -1) (list (list midpeg midpeg lftpeg) nil))))
                    (cons (list ritpeg midpeg lftpeg) (list (list '(3 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;Flat State
                                                            (list '(2 1) (list (list midpeg midpeg ritpeg) (list midpeg midpeg lftpeg)))
                                                            (list '(0 -1) (list (list ritpeg midpeg lftpeg) nil))))
                    (cons (list lftpeg ritpeg lftpeg) (list (list '(4 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(3 2) (list (list midpeg midpeg ritpeg) (list midpeg midpeg lftpeg)))
                                                            (list '(1 0) (list (list lftpeg midpeg lftpeg) nil))))
                    (cons (list midpeg ritpeg lftpeg) (list (list '(5 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;Flat State
                                                            (list '(4 2) (list (list midpeg midpeg ritpeg) (list lftpeg midpeg lftpeg)))
                                                            (list '(2 1) (list (list lftpeg midpeg lftpeg) (list lftpeg ritpeg lftpeg)))))
                    (cons (list ritpeg ritpeg lftpeg) (list (list '(5 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(4 2) (list (list midpeg midpeg ritpeg) (list lftpeg midpeg lftpeg)))
                                                            (list '(2 0) (list (list lftpeg midpeg lftpeg) (list ritpeg ritpeg lftpeg)))))
                    (cons (list lftpeg lftpeg midpeg) (list (list '(4 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(1 0) (list (list lftpeg lftpeg ritpeg) (list lftpeg lftpeg midpeg)))
                                                            (list '(3 1) (list (list ritpeg midpeg ritpeg) (list lftpeg lftpeg ritpeg)))))
                    (cons (list midpeg lftpeg midpeg) (list (list '(5 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(2 0) (list (list lftpeg lftpeg ritpeg) (list midpeg lftpeg midpeg)))
                                                            (list '(4 2) (list (list ritpeg midpeg ritpeg) (list lftpeg lftpeg ritpeg)))))
                    (cons (list ritpeg lftpeg midpeg) (list (list '(5 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;Flat State
                                                            (list '(2 1) (list (list lftpeg lftpeg ritpeg) (list lftpeg lftpeg midpeg)))
                                                            (list '(4 2) (list (list ritpeg midpeg ritpeg) (list lftpeg lftpeg ritpeg)))))
                    (cons (list lftpeg midpeg midpeg) (list (list '(7 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(4 0) (list (list lftpeg lftpeg ritpeg) (list lftpeg midpeg midpeg)))
                                                            (list '(5 3) (list (list lftpeg midpeg lftpeg) (list ritpeg ritpeg lftpeg)))))
                    (cons (list midpeg midpeg midpeg) (list (list '(7 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(4 0) (list (list lftpeg lftpeg ritpeg) (list midpeg midpeg midpeg)))
                                                            (list '(6 4) (list (list ritpeg midpeg ritpeg) (list lftpeg lftpeg ritpeg)))))
                    (cons (list ritpeg midpeg midpeg) (list (list '(6 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(3 1) (list (list lftpeg lftpeg ritpeg) (list lftpeg midpeg midpeg)))
                                                            (list '(5 3) (list (list ritpeg midpeg ritpeg) (list lftpeg lftpeg ritpeg)))))
                    (cons (list lftpeg ritpeg midpeg) (list (list '(7 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;Flat State
                                                            (list '(4 2) (list (list lftpeg lftpeg ritpeg) (list midpeg lftpeg midpeg)))
                                                            (list '(4 2) (list (list lftpeg midpeg lftpeg) (list ritpeg ritpeg lftpeg)))))
                    (cons (list midpeg ritpeg midpeg) (list (list '(6 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(3 1) (list (list lftpeg lftpeg ritpeg) (list midpeg lftpeg midpeg)))
                                                            (list '(4 2) (list (list lftpeg midpeg lftpeg) (list ritpeg ritpeg lftpeg)))))
                    (cons (list ritpeg ritpeg midpeg) (list (list '(6 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(4 2) (list (list lftpeg lftpeg ritpeg) (list midpeg lftpeg midpeg)))
                                                            (list '(3 1) (list (list lftpeg midpeg lftpeg) (list ritpeg ritpeg lftpeg)))))
                    (cons (list lftpeg lftpeg ritpeg) (list (list '(3 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list lftpeg lftpeg ritpeg) nil))
                                                            (list '(2 0) (list (list ritpeg midpeg ritpeg) (list lftpeg lftpeg ritpeg)))))
                    (cons (list midpeg lftpeg ritpeg) (list (list '(3 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;Flat State
                                                            (list '(0 -1) (list (list midpeg lftpeg ritpeg) nil))
                                                            (list '(2 1) (list (list ritpeg midpeg ritpeg) (list ritpeg lftpeg ritpeg)))))
                    (cons (list ritpeg lftpeg ritpeg) (list (list '(2 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list ritpeg lftpeg ritpeg) nil))
                                                            (list '(1 0) (list (list ritpeg midpeg ritpeg) (list ritpeg lftpeg ritpeg)))))
                    (cons (list lftpeg midpeg ritpeg) (list (list '(0 -1) (list (list lftpeg midpeg ritpeg) nil))                            ;Goal Flat State
                                                            (list '(0 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list lftpeg midpeg ritpeg) nil))))
                    (cons (list midpeg midpeg ritpeg) (list (list '(1 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list midpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list midpeg midpeg ritpeg) nil))))
                    (cons (list ritpeg midpeg ritpeg) (list (list '(1 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list ritpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list ritpeg midpeg ritpeg) nil))))
                    (cons (list lftpeg ritpeg ritpeg) (list (list '(1 -1) (list (list lftpeg midpeg ritpeg) nil))
                                                            (list '(0 -1) (list (list lftpeg ritpeg ritpeg) nil))
                                                            (list '(1 0) (list (list lftpeg midpeg ritpeg) (list lftpeg ritpeg ritpeg)))))
                    (cons (list midpeg ritpeg ritpeg) (list (list '(2 -1) (list (list lftpeg midpeg ritpeg) nil)) 
                                                            (list '(0 -1) (list (list midpeg ritpeg ritpeg) nil))
                                                            (list '(2 1) (list (list lftpeg midpeg ritpeg) (list lftpeg ritpeg ritpeg)))))
                    (cons (list ritpeg ritpeg ritpeg) (list (list '(2 -1) (list (list lftpeg midpeg ritpeg) nil)) 
                                                            (list '(0 -1) (list (list ritpeg ritpeg ritpeg) nil))
                                                            (list '(2 0) (list (list lftpeg midpeg ritpeg) (list ritpeg ritpeg ritpeg)))))))
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;;  Explanation of what's in *states*
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;((A A A)                       ;current state
;; ((5 -1) ((A B C) nil))        ;moves to goal
;; ((4 0) ((B B C) (A A A)))     ;moves to place large disk or clear peg c (resulting states)
;; ((2 0) ((C B A) (A A A))))    ;moves to place medium disk or clear peg b (resulting states)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The interface for running the model on the web
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar *WWW-interface*)

(setf  *WWW-interface* 
      '((:heading "Model for Problem Solving: Increased Planning with Practice" 2)
        (:table)
        
        (:table)
        "Noise:" (:string :sy *noise*  1)  (:new-row)
        "History:"  (:string :sy *history* 2)  (:new-row)
        "Random History:"  (:string :sy *random-history* 200)  (:new-row)
        "Scale:" (:string :sy *scale* .75) (:new-row)
        "Move Time:" (:string :sy *move-time* 4) (:new-row)
        "Number of runs (1-20):"  (:string :sy *runs* 10)  
        
        (:table-end)
        
        (:table)
        (:checkbox "Graphic output" :sy *graphic*  t) (:new-row)
        (:table-end)
        (:table-end)
        
        (:new-para)
        
        (:button "Show Experiment Results" "(if *graphic*
                                               (progn
                                                  (display-exp1-graphs nil *fp-E1* nil *MovesData1b*)
                                                  (display-exp2-graphs nil *fp-E2* nil *MovesData2b*))
                                               (format *standard-output* \"~%Output is only displayed in graphs, so you must enable them first.~%\"))")
        (:new-para)
        (:button "Run model" "(if (and (numberp *noise*) (numberp *history*)
                                       (numberp *random-history*) (numberp *scale*)
                                       (numberp *move-time*) (numberp *runs*))
                                  (progn
                                    
                                    (run-both (min 20 (max 1 *runs*))))
                                  (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:"
        (:new-para)
        "- It usually takes about 3 minutes for 10 runs of the model"
        (:use-script)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Functions for running the Model
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;Main function for running the model
(defun run-both (n)
  (format t "~%~%Running model on Experiment 1~%~d participants per condition~%" n)
  (exp1 n *TimeData1* *MovesData1b* *Fp-Data1*)
  (format t "~%~%~%~%Running model on Experiment 2~%~d participants per condition~%" n)
  (exp2 n *TimeData2* *MovesData2b* *Fp-train-Data2* *Fp-trans-Data2*)
  (format t "~%Done running both experiments~%~%~%"))

;;Runs either experiment n times
(defun full-run (exp n)
  (format t "~%~%Running model on Experiment ~d~%~d participants per condition~%" exp n)
  (if (equal exp 1)
      (exp1 n *TimeData1* *MovesData1b* *Fp-Data1*)
      (exp2 n *TimeData2* *MovesData2b* *Fp-train-Data2* *Fp-trans-Data2*))
  (format t "~%Done running Experiment ~d~%~%~%" exp))

;;Runs the model on experiment 1 and compares its performance to the data
(defun exp1 (n timedata movesdata fp-data)
  (let (result1 result2 result3 result4 *time* *moves* *fp-model* *fpall*
                result1b result2b result3a result3b result3c result3d)
    (setf result1 (repeat  '((reset)
                             (gather (list (repeat '(hard) 6)
                                           (repeat '(hard) 6)) :indices '("First six" "Second six"))
                             ) n))
;    (format t "~%First condition done - Hard-Hard.")
;    (print-uses) ;Will print out frequency of each production firing (cumulative)
    (setf result2 (repeat  '((reset)
                            (gather (list (repeat '(hard) 6)
                                           (repeat '(easy) 6)) :indices '("First six" "Second six"))
                             ) n))
;    (format t "~%Second condition done - Hard-Easy")
;    (print-uses) ;Will print out frequency of each production firing (cumulative)
    (setf result1b (repeat  '((reset)
                              (gather (list (repeat '(easy) 6)
                                            (repeat '(hard) 6)) :indices '("First six" "Second six"))
                              ) n))
;    (format t "~%Third condition done - Easy-Hard.")
;    (print-uses) ;Will print out frequency of each production firing (cumulative)
    (setf result2b (repeat  '((reset)
                              (gather (list (repeat '(easy) 6)
                                            (repeat '(easy) 6)) :indices '("First six" "Second six"))
                              ) n))    
;    (format t "~%Fourth condition done - Easy-Easy")
;    (print-uses) ;Will print out frequency of each production firing (cumulative)

    (setf result3 (gather (list (choose result1 'third)) :label "fp"))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (aggregate (transpose result3)))
    (setf result4 (matrix result3))
    (when *path* (with-open-file 
                   (out-stream (make-pathname :directory *path* :name (symbol-name (gensym "HardHard"))) :direction :output :if-exists :append :if-does-not-exist :create)
                   (dotimes (h n)
                     (format out-stream "~%HH~c" #\tab)
                     (dotimes (i 2)
                       (dotimes (j 6)
                         (format out-stream "~d~c" (aref result4 h i j) #\tab))))))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (categorize (transpose result3) '(5 6 T)))
    (setf result3 (frequency result3 :factor (/ 1.0 n)))
    (setf result4 (matrix result3))
    (setf *fp-model* (list (aref result4 0 0) (aref result4 0 2) (aref result4 0 4) (aref result4 0 6) (aref result4 0 8) (aref result4 0 10)
                           (aref result4 0 1) (aref result4 0 3) (aref result4 0 5) (aref result4 0 7) (aref result4 0 9) (aref result4 0 11)    ;end of 5-move final paths
                           (aref result4 1 0) (aref result4 1 2) (aref result4 1 4) (aref result4 1 6) (aref result4 1 8) (aref result4 1 10)
                           (aref result4 1 1) (aref result4 1 3) (aref result4 1 5) (aref result4 1 7) (aref result4 1 9) (aref result4 1 11)))
    (setf *fpALL* *fp-model*)
    (setf result3 (gather (list (choose result2 'third)) :label "fp"))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (aggregate (transpose result3)))
    (setf result4 (matrix result3))
    (when *path* (with-open-file 
                   (out-stream (make-pathname :directory *path* :name (symbol-name (gensym "HardEasy"))) :direction :output :if-exists :append :if-does-not-exist :create)
                   (dotimes (h n)
                     (format out-stream "~%HE~c" #\tab)
                     (dotimes (i 2)
                       (dotimes (j 6)
                         (format out-stream "~d~c" (aref result4 h i j) #\tab))))))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (categorize (transpose result3) '(5 6 T)))
    (setf result3 (frequency result3 :factor (/ 1.0 n)))
    (setf result4 (matrix result3))
    (setf *fp-model* (list (aref result4 0 0) (aref result4 0 2) (aref result4 0 4) (aref result4 0 6) (aref result4 0 8) (aref result4 0 10)
                           (aref result4 0 1) (aref result4 0 3) (aref result4 0 5) (aref result4 0 7) (aref result4 0 9) (aref result4 0 11)    ;end of 5-move final paths
                           (aref result4 1 0) (aref result4 1 2) (aref result4 1 4) (aref result4 1 6) (aref result4 1 8) (aref result4 1 10)
                           (aref result4 1 1) (aref result4 1 3) (aref result4 1 5) (aref result4 1 7) (aref result4 1 9) (aref result4 1 11)))
    (setf *fpALL* (append *fpALL* *fp-model*))
    (setf result3 (gather (list (choose result1b 'third)) :label "fp"))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (aggregate (transpose result3)))
    (setf result4 (matrix result3))
    (when *path* (with-open-file 
                   (out-stream (make-pathname :directory *path* :name (symbol-name (gensym "EasyHard"))) :direction :output :if-exists :append :if-does-not-exist :create)
                   (dotimes (h n)
                     (format out-stream "~%EH~c" #\tab)
                     (dotimes (i 2)
                       (dotimes (j 6)
                         (format out-stream "~d~c" (aref result4 h i j) #\tab))))))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (categorize (transpose result3) '(5 6 T)))
    (setf result3 (frequency result3 :factor (/ 1.0 n)))
    (setf result4 (matrix result3))
    (setf *fp-model* (list (aref result4 0 0) (aref result4 0 2) (aref result4 0 4) (aref result4 0 6) (aref result4 0 8) (aref result4 0 10)
                           (aref result4 0 1) (aref result4 0 3) (aref result4 0 5) (aref result4 0 7) (aref result4 0 9) (aref result4 0 11)    ;end of 5-move final paths
                           (aref result4 1 0) (aref result4 1 2) (aref result4 1 4) (aref result4 1 6) (aref result4 1 8) (aref result4 1 10)
                           (aref result4 1 1) (aref result4 1 3) (aref result4 1 5) (aref result4 1 7) (aref result4 1 9) (aref result4 1 11)))
    (setf *fpALL* (append *fpALL* *fp-model*))
    (setf result3 (gather (list (choose result2b 'third)) :label "fp"))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (aggregate (transpose result3)))
    (setf result4 (matrix result3))
    (when *path* (with-open-file 
                   (out-stream (make-pathname :directory *path* :name (symbol-name (gensym "EasyEasy"))) :direction :output :if-exists :append :if-does-not-exist :create)
                   (dotimes (h n)
                     (format out-stream "~%EE~c" #\tab)
                     (dotimes (i 2)
                       (dotimes (j 6)
                         (format out-stream "~d~c" (aref result4 h i j) #\tab))))))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (categorize (transpose result3) '(5 6 T)))
    (setf result3 (frequency result3 :factor (/ 1.0 n)))
    (setf result4 (matrix result3))
    (setf *fp-model* (list (aref result4 0 0) (aref result4 0 2) (aref result4 0 4) (aref result4 0 6) (aref result4 0 8) (aref result4 0 10)
                           (aref result4 0 1) (aref result4 0 3) (aref result4 0 5) (aref result4 0 7) (aref result4 0 9) (aref result4 0 11)    ;end of 5-move final paths
                           (aref result4 1 0) (aref result4 1 2) (aref result4 1 4) (aref result4 1 6) (aref result4 1 8) (aref result4 1 10)
                           (aref result4 1 1) (aref result4 1 3) (aref result4 1 5) (aref result4 1 7) (aref result4 1 9) (aref result4 1 11)))
    (setf *fpALL* (append *fpALL* *fp-model*))
    (pprint "Final Paths")
    (correlation *fpALL* *fp-E1*)
    (mean-deviation *fpALL* *fp-E1*)

    (pprint "Solution Length (Number of Moves)")
    (setf result3a (gather (list (choose result1 'second)) :label "H-H"))
    (setf result3b (gather (list (choose result2 'second)) :label "H-E"))
    (setf result3c (gather (list (choose result1b 'second)) :label "E-H"))
    (setf result3d (gather (list (choose result2b 'second)) :label "E-E"))
    (setf result3a (average (average result3a)))
    (setf result3b (average (average result3b)))
    (setf result3c (average (average result3c)))
    (setf result3d (average (average result3d)))
    (setf result3 (gather (list result3a result3b result3c result3d) :label "moves"))
;    (tabulate result3) ;prints out move-data for model
    (correlation result3 movesdata)
    (mean-deviation result3 movesdata)

    (setf result3 (aggregate (aggregate (aggregate result3))))
    

    (when *graphic*
      (display-exp1-graphs *fpALL* *fp-E1* (matrix result3) movesdata)) 

    ))

;;Runs the model on experiment 2 and compares its performance to the data
(defun exp2 (n timedata movesdata *Fp-train-Data2* *Fp-trans-Data2*)
  (let (result1 result2 result3 result4 *time* *moves* *fpALL* *fptraining* *fptransfer*
                result3a result3b)
    (setf result1 (repeat  '((reset)
                             (gather (list (repeat '(hard) 6)
                                           (repeat '(hard) 6)
                                           (repeat '(transfer) 6)) :indices '("First six" "Second six" "Transfer"))
                             )
                           n))
;    (format t "~%First condition done - Hard Training.")
;    (print-uses) ;Will print out frequency of each production firing (cumulative)
    (setf result2 (repeat  '((reset)
                             (gather (list (repeat '(easy) 6)
                                           (repeat '(easy) 6)
                                           (repeat '(transfer) 6)) :indices '("First six" "Second six" "Transfer"))
                             )
                           n))
;    (format t "~%Second condition done - Easy Training.")
;    (print-uses) ;Will print out frequency of each production firing (cumulative)
    (setf result3 (gather (list (choose result1 'third)) :label "fpaths"))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (aggregate (transpose result3)))
    (setf result4 (matrix result3))
    (when *path* (with-open-file 
                   (out-stream (make-pathname :directory *path* :name (symbol-name (gensym "TrainHard"))) :direction :output :if-exists :append :if-does-not-exist :create)
                   (dotimes (h n)
                     (format out-stream "~%HH~c" #\tab)
                     (dotimes (i 3)
                       (dotimes (j 6)
                         (format out-stream "~d~c" (aref result4 h i j) #\tab))))))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (categorize (transpose result3) '(5 6 7 8 9 T)))
    (setf result3 (frequency result3 :factor (/ 1.0 n)))
    (setf result4 (matrix result3))
    (setf *fptraining* (list (aref result4 0 0) (aref result4 0 3) (aref result4 0 6) (aref result4 0 9) (aref result4 0 12) (aref result4 0 15)
                             (aref result4 0 1) (aref result4 0 4) (aref result4 0 7) (aref result4 0 10) (aref result4 0 13) (aref result4 0 16)   ;end of 5-move final paths
                             (aref result4 1 0) (aref result4 1 3) (aref result4 1 6) (aref result4 1 9) (aref result4 1 12) (aref result4 1 15)
                             (aref result4 1 1) (aref result4 1 4) (aref result4 1 7) (aref result4 1 10) (aref result4 1 13) (aref result4 1 16)))
    (setf *fptransfer* (list (aref result4 2 2) (aref result4 2 5) (aref result4 2 8) (aref result4 2 11) (aref result4 2 14) (aref result4 2 17)   ;end of 7-move final paths
                             (aref result4 3 2) (aref result4 3 5) (aref result4 3 8) (aref result4 3 11) (aref result4 3 14) (aref result4 3 17)   ;end of 8-move final paths
                             (aref result4 4 2) (aref result4 4 5) (aref result4 4 8) (aref result4 4 11) (aref result4 4 14) (aref result4 4 17)))
    (setf *fpALL* (append *fptraining* *fptransfer*))
    (setf result3 (gather (list (choose result2 'third)) :label "fpaths"))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (aggregate (transpose result3)))
    (setf result4 (matrix result3))
    (when *path* (with-open-file
                   (out-stream (make-pathname :directory *path* :name (symbol-name (gensym "TrainEasy"))) :direction :output :if-exists :append :if-does-not-exist :create)
                   (dotimes (h n)
                     (format out-stream "~%EE~c" #\tab)
                     (dotimes (i 3)
                       (dotimes (j 6)
                         (format out-stream "~d~c" (aref result4 h i j) #\tab))))))
    (setf result3 (aggregate (transpose result3)))
    (setf result3 (categorize (transpose result3) '(5 6 7 8 9 T)))
    (setf result3 (frequency result3 :factor (/ 1.0 n)))
    (setf result4 (matrix result3))
    (setf *fptraining* (list (aref result4 0 0) (aref result4 0 3) (aref result4 0 6) (aref result4 0 9) (aref result4 0 12) (aref result4 0 15)
                             (aref result4 0 1) (aref result4 0 4) (aref result4 0 7) (aref result4 0 10) (aref result4 0 13) (aref result4 0 16)   ;end of 5-move final paths
                             (aref result4 1 0) (aref result4 1 3) (aref result4 1 6) (aref result4 1 9) (aref result4 1 12) (aref result4 1 15)
                             (aref result4 1 1) (aref result4 1 4) (aref result4 1 7) (aref result4 1 10) (aref result4 1 13) (aref result4 1 16)))
    (setf *fptransfer* (list (aref result4 2 2) (aref result4 2 5) (aref result4 2 8) (aref result4 2 11) (aref result4 2 14) (aref result4 2 17)   ;end of 7-move final paths
                             (aref result4 3 2) (aref result4 3 5) (aref result4 3 8) (aref result4 3 11) (aref result4 3 14) (aref result4 3 17)   ;end of 8-move final paths
                             (aref result4 4 2) (aref result4 4 5) (aref result4 4 8) (aref result4 4 11) (aref result4 4 14) (aref result4 4 17)))
    (pprint "Final Paths")
    (setf *fpALL* (append *fpALL* (append *fptraining* *fptransfer*)))
    (correlation *fpALL* *fp-E2*)
    (mean-deviation *fpALL* *fp-E2*)

    (pprint "Solution Length (Number of Moves)")
    (setf result3a (gather (list (choose result1 'second)) :label "hard"))
    (setf result3b (gather (list (choose result2 'second)) :label "easy"))
    (setf result3a (average (average result3a)))
    (setf result3b (average (average result3b)))
    (setf result3 (gather (list result3a result3b) :label "moves"))
;    (tabulate result3) ;prints out move-data for model
    (correlation result3 movesdata)
    (mean-deviation result3 movesdata)
    
    (setf result3 (aggregate (aggregate (aggregate result3))))
    

    (when *graphic*
      (display-exp2-graphs *fpALL* *fp-E2* (matrix result3) movesdata))
    ))



(defun display-exp1-graphs (mdata1 expdata1 mdata2 expdata2)
  (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 500 
        height = 500> 
        <PARAM name=\"title\" value=\"5 Move Final Path Lengths\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"12\">
        <PARAM name=\"ymax\" value=\"1.0\">
        <PARAM name=\"ymin\" value=\"0.0\">
        <PARAM name=\"longestline\" value=\"24\">
        <PARAM name=\"numlines\" value=\"~S\">
        <PARAM name=\"ydiv\" value=\".1\">
        <PARAM name=\"yspacing\" value=\".25\">
        <PARAM name=\"xspacing\" value=\"1\">
        <PARAM name=\"xname\" value=\"Problem Number\">
        <PARAM name=\"yname\" value=\"Proportion of Solns.\">
        <PARAM name=\"name0\" value=\"Experimental - hh\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"6553\">
        <PARAM name=\"xval0\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name1\" value=\"Experimental - he\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"6553\">
        <PARAM name=\"xval1\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name2\" value=\"Experimental - eh\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"6553\">
        <PARAM name=\"xval2\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\"> 
        <PARAM name=\"name3\" value=\"Experimental - ee\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"6553\">
        <PARAM name=\"xval3\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       "
    (if mdata1 8 4))

    (dotimes (i 4)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" i)
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ j (* i 24)) expdata1))) 
      
      (format *standard-output* "\">"))

    
    (when mdata1
      (format *standard-output* "
        <PARAM name=\"name4\" value=\"Simulation - hh\">
        <PARAM name=\"lcolor4\" value=\"0\">
        <PARAM name=\"lstyle4\" value=\"2\">
        <PARAM name=\"xval4\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name5\" value=\"Simulation - he\">
        <PARAM name=\"lcolor5\" value=\"1\">
        <PARAM name=\"lstyle5\" value=\"2\">
        <PARAM name=\"xval5\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name6\" value=\"Simulation - eh\">
        <PARAM name=\"lcolor6\" value=\"2\">
        <PARAM name=\"lstyle6\" value=\"2\">
        <PARAM name=\"xval6\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name7\" value=\"Simulation - ee\">
        <PARAM name=\"lcolor7\" value=\"3\">
        <PARAM name=\"lstyle7\" value=\"2\">
        <PARAM name=\"xval7\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       ")

      (dotimes (i 4)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 4))
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ j (* i 24)) mdata1))) 
      
      (format *standard-output* "\">")))


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

  (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 500 
        height = 500> 
        <PARAM name=\"title\" value=\"6 Move Final Path Lengths\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"12\">
        <PARAM name=\"ymax\" value=\"1.0\">
        <PARAM name=\"ymin\" value=\"0.0\">
        <PARAM name=\"longestline\" value=\"24\">
        <PARAM name=\"numlines\" value=\"~S\">
        <PARAM name=\"ydiv\" value=\".1\">
        <PARAM name=\"yspacing\" value=\".25\">
        <PARAM name=\"xspacing\" value=\"1\">
        <PARAM name=\"xname\" value=\"Problem Number\">
        <PARAM name=\"yname\" value=\"Proportion of Solns.\">
        <PARAM name=\"name0\" value=\"Experimental - hh\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"6553\">
        <PARAM name=\"xval0\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name1\" value=\"Experimental - he\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"6553\">
        <PARAM name=\"xval1\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name2\" value=\"Experimental - eh\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"6553\">
        <PARAM name=\"xval2\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\"> 
        <PARAM name=\"name3\" value=\"Experimental - ee\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"6553\">
        <PARAM name=\"xval3\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       "
    (if mdata1 8 4))

    (dotimes (i 4)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" i)
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ 12 j (* i 24)) expdata1))) 
      
      (format *standard-output* "\">"))

    
    (when mdata1
      (format *standard-output* "
        <PARAM name=\"name4\" value=\"Simulation - hh\">
        <PARAM name=\"lcolor4\" value=\"0\">
        <PARAM name=\"lstyle4\" value=\"2\">
        <PARAM name=\"xval4\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name5\" value=\"Simulation - he\">
        <PARAM name=\"lcolor5\" value=\"1\">
        <PARAM name=\"lstyle5\" value=\"2\">
        <PARAM name=\"xval5\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name6\" value=\"Simulation - eh\">
        <PARAM name=\"lcolor6\" value=\"2\">
        <PARAM name=\"lstyle6\" value=\"2\">
        <PARAM name=\"xval6\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name7\" value=\"Simulation - ee\">
        <PARAM name=\"lcolor7\" value=\"3\">
        <PARAM name=\"lstyle7\" value=\"2\">
        <PARAM name=\"xval7\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       ")

      (dotimes (i 4)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 4))
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ 12 j (* i 24)) mdata1))) 
      
      (format *standard-output* "\">")))


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


   
  (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 500 
        height = 400> 
        <PARAM name=\"title\" value=\"Moves\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"12\">
        <PARAM name=\"ymax\" value=\"16\">
        <PARAM name=\"ymin\" value=\"4\">
        <PARAM name=\"longestline\" value=\"12\">
        <PARAM name=\"numlines\" value=\"~S\">
        <PARAM name=\"ydiv\" value=\"1\">
        <PARAM name=\"yspacing\" value=\"2\">
        <PARAM name=\"xspacing\" value=\"1\">
        <PARAM name=\"xname\" value=\"Problem Number\">
        <PARAM name=\"yname\" value=\"# of Moves\">
        <PARAM name=\"name0\" value=\"Experimental - hh\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"6553\">
        <PARAM name=\"xval0\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name1\" value=\"Experimental - he\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"6553\">
        <PARAM name=\"xval1\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name2\" value=\"Experimental - eh\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"6553\">
        <PARAM name=\"xval2\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\"> 
        <PARAM name=\"name3\" value=\"Experimental - ee\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"6553\">
        <PARAM name=\"xval3\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       "
    (if mdata2 8 4))

    (dotimes (i 4)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" i)
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ j (* i 12)) expdata2))) 
      
      (format *standard-output* "\">"))

    
    (when mdata2
      (format *standard-output* "
        <PARAM name=\"name4\" value=\"Simulation - hh\">
        <PARAM name=\"lcolor4\" value=\"0\">
        <PARAM name=\"lstyle4\" value=\"2\">
        <PARAM name=\"xval4\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name5\" value=\"Simulation - he\">
        <PARAM name=\"lcolor5\" value=\"1\">
        <PARAM name=\"lstyle5\" value=\"2\">
        <PARAM name=\"xval5\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name6\" value=\"Simulation - eh\">
        <PARAM name=\"lcolor6\" value=\"2\">
        <PARAM name=\"lstyle6\" value=\"2\">
        <PARAM name=\"xval6\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\"> 
        <PARAM name=\"name7\" value=\"Simulation - ee\">
        <PARAM name=\"lcolor7\" value=\"3\">
        <PARAM name=\"lstyle7\" value=\"2\">
        <PARAM name=\"xval7\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       ")

      (dotimes (i 4)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 4))
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (aref mdata2 (+ (* i 12) j)))) 
      
      (format *standard-output* "\">")))


    (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 display-exp2-graphs (mdata1 expdata1 mdata2 expdata2)
  (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 500 
        height = 500> 
        <PARAM name=\"title\" value=\"Final Path length - Training\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"12\">
        <PARAM name=\"ymax\" value=\"1.0\">
        <PARAM name=\"ymin\" value=\"0.0\">
        <PARAM name=\"longestline\" value=\"12\">
        <PARAM name=\"numlines\" value=\"~S\">
        <PARAM name=\"ydiv\" value=\".1\">
        <PARAM name=\"yspacing\" value=\".25\">
        <PARAM name=\"xspacing\" value=\"1\">
        <PARAM name=\"xname\" value=\"Problem Number\">
        <PARAM name=\"yname\" value=\"Proportion of Soln.\">
        <PARAM name=\"name0\" value=\"Experimental - 5 move final paths (Hard training)\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"6553\">
        <PARAM name=\"xval0\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name1\" value=\"Experimental - 5 move final paths (Easy training)\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"6553\">
        <PARAM name=\"xval1\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name2\" value=\"Experimental - 6 move final paths (Hard training)\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"6553\">
        <PARAM name=\"xval2\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name3\" value=\"Experimental - 6 move final paths (Easy training)\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"6553\">
        <PARAM name=\"xval3\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        "
    (if mdata1 8 4))
  
  (dotimes (i 2)
    (format *standard-output* "<PARAM name=\"yval~a\" value=\"" i)
    (dotimes (j 12)
      (format *standard-output* "~6,4f;" (nth (+ j (* i 42)) expdata1))) 
    
    (format *standard-output* "\">"))
  
  (dotimes (i 2)
    (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 2))
    (dotimes (j 12)
      (format *standard-output* "~6,4f;" (nth (+ j 12 (* i 42)) expdata1))) 
    
    (format *standard-output* "\">"))
  
  
  (when mdata1
    (format *standard-output* "
        <PARAM name=\"name4\" value=\"Simulation - 5 move final paths (Hard training)\">
        <PARAM name=\"lcolor4\" value=\"0\">
        <PARAM name=\"lstyle4\" value=\"2\">
        <PARAM name=\"xval4\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name5\" value=\"Simulation - 5 move final paths (Easy training)\">
        <PARAM name=\"lcolor5\" value=\"1\">
        <PARAM name=\"lstyle5\" value=\"2\">
        <PARAM name=\"xval5\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name6\" value=\"Simulation - 6 move final paths (Hard training)\">
        <PARAM name=\"lcolor6\" value=\"2\">
        <PARAM name=\"lstyle6\" value=\"2\">
        <PARAM name=\"xval6\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
        <PARAM name=\"name7\" value=\"Simulation - 6 move final paths (Easy training)\">
        <PARAM name=\"lcolor7\" value=\"3\">
        <PARAM name=\"lstyle7\" value=\"2\">
        <PARAM name=\"xval7\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;\">
       ")
    
    (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 4))
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ j (* i 42)) mdata1))) 
      
      (format *standard-output* "\">"))
    
    
    (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 6))
      (dotimes (j 12)
        (format *standard-output* "~6,4f;" (nth (+ j 12 (* i 42)) mdata1))) 
      
      (format *standard-output* "\">")))

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

  (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 500 
        height = 500> 
        <PARAM name=\"title\" value=\"Final Path length - Transfer\">
        <PARAM name=\"xmin\" value=\"13\">
        <PARAM name=\"xmax\" value=\"18\">
        <PARAM name=\"ymax\" value=\"1.0\">
        <PARAM name=\"ymin\" value=\"0.0\">
        <PARAM name=\"longestline\" value=\"6\">
        <PARAM name=\"numlines\" value=\"~S\">
        <PARAM name=\"ydiv\" value=\".1\">
        <PARAM name=\"yspacing\" value=\".25\">
        <PARAM name=\"xspacing\" value=\"1\">
        <PARAM name=\"xname\" value=\"Problem Number\">
        <PARAM name=\"yname\" value=\"Proportion of Soln.\">
        <PARAM name=\"name0\" value=\"Experimental - 7 move final paths (Hard training)\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"6553\">
        <PARAM name=\"xval0\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name1\" value=\"Experimental - 7 move final paths (Easy training)\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"6553\">
        <PARAM name=\"xval1\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name2\" value=\"Experimental - 8 move final paths (Hard training)\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"6553\">
        <PARAM name=\"xval2\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name3\" value=\"Experimental - 8 move final paths (Easy training)\">
        <PARAM name=\"lcolor3\" value=\"3\">
        <PARAM name=\"lstyle3\" value=\"6553\">
        <PARAM name=\"xval3\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name4\" value=\"Experimental - 9 move final paths (Hard training)\">
        <PARAM name=\"lcolor4\" value=\"4\">
        <PARAM name=\"lstyle4\" value=\"6553\">
        <PARAM name=\"xval4\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name5\" value=\"Experimental - 9 move final paths (Easy training)\">
        <PARAM name=\"lcolor5\" value=\"5\">
        <PARAM name=\"lstyle5\" value=\"6553\">
        <PARAM name=\"xval5\" value=\"13;14;15;16;17;18;\">
        "
    (if mdata1 12 6))
  
  (dotimes (i 2)
    (format *standard-output* "<PARAM name=\"yval~a\" value=\"" i)
    (dotimes (j 6)
      (format *standard-output* "~6,4f;" (nth (+ j 24 (* i 42)) expdata1))) 
    
    (format *standard-output* "\">"))
  
  (dotimes (i 2)
    (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 2))
    (dotimes (j 6)
      (format *standard-output* "~6,4f;" (nth (+ j 30 (* i 42)) expdata1))) 
    
    (format *standard-output* "\">"))
  
  (dotimes (i 2)
    (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 4))
    (dotimes (j 6)
      (format *standard-output* "~6,4f;" (nth (+ j 36 (* i 42)) expdata1))) 
    
    (format *standard-output* "\">"))

  (when mdata1
    (format *standard-output* "
        <PARAM name=\"name6\" value=\"Simulation - 7 move final paths (Hard training)\">
        <PARAM name=\"lcolor6\" value=\"0\">
        <PARAM name=\"lstyle6\" value=\"2\">
        <PARAM name=\"xval6\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name7\" value=\"Simulation - 7 move final paths (Easy training)\">
        <PARAM name=\"lcolor7\" value=\"1\">
        <PARAM name=\"lstyle7\" value=\"2\">
        <PARAM name=\"xval7\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name8\" value=\"Simulation - 8 move final paths (Hard training)\">
        <PARAM name=\"lcolor8\" value=\"2\">
        <PARAM name=\"lstyle8\" value=\"2\">
        <PARAM name=\"xval8\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name9\" value=\"Simulation - 8 move final paths (Easy training)\">
        <PARAM name=\"lcolor9\" value=\"3\">
        <PARAM name=\"lstyle9\" value=\"2\">
        <PARAM name=\"xval9\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name10\" value=\"Simulation - 9 move final paths (Hard training)\">
        <PARAM name=\"lcolor10\" value=\"4\">
        <PARAM name=\"lstyle10\" value=\"2\">
        <PARAM name=\"xval10\" value=\"13;14;15;16;17;18;\">
        <PARAM name=\"name11\" value=\"Simulation - 9 move final paths (Easy training)\">
        <PARAM name=\"lcolor11\" value=\"5\">
        <PARAM name=\"lstyle11\" value=\"2\">
        <PARAM name=\"xval11\" value=\"13;14;15;16;17;18;\">
       ")
    
    (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 6))
      (dotimes (j 6)
        (format *standard-output* "~6,4f;" (nth (+ j 24 (* i 42)) mdata1))) 
      
      (format *standard-output* "\">"))
    
    
    (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 8))
      (dotimes (j 6)
        (format *standard-output* "~6,4f;" (nth (+ j 30 (* i 42)) mdata1))) 
      
      (format *standard-output* "\">"))
    
    (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 10))
      (dotimes (j 6)
        (format *standard-output* "~6,4f;" (nth (+ j 36 (* i 42)) mdata1))) 
      
      (format *standard-output* "\">")))

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


    
  (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 500 
        height = 400> 
        <PARAM name=\"title\" value=\"Moves\">
        <PARAM name=\"xmin\" value=\"1\">
        <PARAM name=\"xmax\" value=\"18\">
        <PARAM name=\"ymax\" value=\"22\">
        <PARAM name=\"ymin\" value=\"4\">
        <PARAM name=\"longestline\" value=\"18\">
        <PARAM name=\"numlines\" value=\"~S\">
        <PARAM name=\"ydiv\" value=\"1\">
        <PARAM name=\"yspacing\" value=\"2\">
        <PARAM name=\"xspacing\" value=\"1\">
        <PARAM name=\"xname\" value=\"Problem Number\">
        <PARAM name=\"yname\" value=\"# of Moves\">
        <PARAM name=\"name0\" value=\"Experimental - hard\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"6553\">
        <PARAM name=\"xval0\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;\">
        <PARAM name=\"name1\" value=\"Experimental - easy\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"6553\">
        <PARAM name=\"xval1\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;\">
       "
    (if mdata2 4 2))

    (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" i)
      (dotimes (j 18)
        (format *standard-output* "~6,4f;" (nth (+ j (* i 18)) expdata2))) 
      
      (format *standard-output* "\">"))

    
    (when mdata2
      (format *standard-output* "
        <PARAM name=\"name2\" value=\"Simulation - hh\">
        <PARAM name=\"lcolor2\" value=\"0\">
        <PARAM name=\"lstyle2\" value=\"2\">
        <PARAM name=\"xval2\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;\">
        <PARAM name=\"name3\" value=\"Simulation - he\">
        <PARAM name=\"lcolor3\" value=\"1\">
        <PARAM name=\"lstyle3\" value=\"2\">
        <PARAM name=\"xval3\" value=\"1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;\">
       ")

      (dotimes (i 2)
      (format *standard-output* "<PARAM name=\"yval~a\" value=\"" (+ i 2))
      (dotimes (j 18)
        (format *standard-output* "~6,4f;" (aref mdata2 (+ (* i 18) j)))) 
      
      (format *standard-output* "\">")))


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





;; Runs model on a single easy problem
(defun easy ()
  (let (result *moves* *finalpath*)
    (setf reportflag nil)
    (sgp :v nil)
    (setf *fpathstart* 5)
    (setf result (repeat '((Mod-Chunk Easy Step start)
                           (goal-focus easy)
                           (data (run) *moves* *finalpath*)) 1))))

;; Runs model on a single hard problem
(defun hard ()
  (let (result *moves* *finalpath*)
    (setf reportflag nil)
    (sgp :v nil)
    (setf *fpathstart* 5)
    (setf result (repeat '((Mod-Chunk hard Step start)
                           (goal-focus hard)
                           (data (run) *moves* *finalpath*)) 1))))

;; Runs model on a single transfer (7-move) problem
(defun transfer ()
  (let (result *moves* *finalpath*)
    (setf reportflag nil)
    (sgp :v nil)
    (setf *fpathstart* 7)
    (setf result (repeat '((Mod-Chunk tran Step start)
                           (goal-focus tran)
                           (data (run) *moves* *finalpath*)) 1))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Functions used by the model
;;  -Mostly, these functions perform perceptual-motor aspects of
;;   the task, which would have added unnecessary complexity if
;;   implemented as production rules
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Finds either the current or goal location of a disk
;;  -Both pieces of information are available on the screen at all times
(defun find-peg (size type)
  (no-output
   (cond ((= size 3) (get-slot-value (get-safe-wme 'd3) type))
         ((= size 2) (get-slot-value (get-safe-wme 'd2) type))
         (t (get-slot-value (get-safe-wme 'd1) type))
         )))

;; Determines which, if any, peg is empty in the current problem state
;;  -Again, this information is readily available on the screen
(defun find-empty-peg ()
  (no-output
   (let ((c3 (get-slot-value (get-safe-wme 'd3) 'c))
         (c2 (get-slot-value (get-safe-wme 'd2) 'c))
         (c1 (get-slot-value (get-safe-wme 'd1) 'c))
         (pegs (list lftpeg midpeg ritpeg)))
     (setf pegs (remove c3 pegs :test 'equal))
     (setf pegs (remove c2 pegs :test 'equal))
     (setf pegs (remove c1 pegs :test 'equal))
     (car pegs)
)))

;; Encodes the problem state at the start of each problem
;;  -Information available on the screen
(defun encode-state ()
  (no-output
   (let ((sm (get-slot-value (get-safe-wme (car (last (goal-stack)))) 's1))
         (med (get-slot-value (get-safe-wme (car (last (goal-stack)))) 's2))
         (lg (get-slot-value (get-safe-wme (car (last (goal-stack)))) 's3))
         (sm-g (get-slot-value (get-safe-wme (car (last (goal-stack)))) 'g1))
         (med-g (get-slot-value (get-safe-wme (car (last (goal-stack)))) 'g2))
         (lg-g (get-slot-value (get-safe-wme (car (last (goal-stack)))) 'g3)))
   (mod-chunk-fct 'd1 (list 'c sm 'g sm-g))
   (mod-chunk-fct 'd2 (list 'c med 'g med-g))
   (mod-chunk-fct 'd3 (list 'c lg 'g lg-g))
   (setq *moves* -1)
   (move-disk 1 med sm)
   )))

;; Returns the current problem state as a list of the current locations
;;  of each of the disks
(defun liststate ()
  (list (get-slot-value (get-safe-wme 'd1) 'c)
        (get-slot-value (get-safe-wme 'd2) 'c)
        (get-slot-value (get-safe-wme 'd3) 'c))
  )

;; Moves the specified disk from its current peg to its destination
;;  -Basically achieves what mouse clicks on the screen would do in
;;   the task as presented to participants
(defun move-disk (disk frompeg topeg)
  (no-output
   (let ((c1 nil)
         (c2 nil)
         (c3 nil)
         (pegs (list lftpeg midpeg ritpeg))
         (tostate nil)
         (states2 *states*)
         (mfg2 0))
     (if (equal disk (get-slot-value (get-safe-wme (car (goal-stack))) 'disk))
         (mod-chunk-fct (get-safe-wme (car (goal-stack))) (list 'c topeg))
;         (format t "~d     ~d~%" disk (get-slot-value (get-safe-wme (car (goal-stack))) 'disk))
       )
     (cond ((= disk 3) (mod-chunk-fct 'd3 (list 'c topeg)))
           ((= disk 2) (mod-chunk-fct 'd2 (list 'c topeg)))
           (t (mod-chunk-fct 'd1 (list 'c topeg)))
           )
     (setf tostate (liststate))
     (setf c1 (car tostate))
     (setf c2 (car (cdr tostate)))
     (setf c3 (car (cddr tostate)))
     (setf pegs (remove (get-slot-value (get-safe-wme frompeg) 'name) pegs :test 'equal))
     (setf pegs (remove (get-slot-value (get-safe-wme topeg) 'name) pegs :test 'equal))
     (if (equal (get-slot-value (get-safe-wme (car (goal-stack))) 'disk) disk)
         (mod-chunk-fct (car (goal-stack)) (list 'c topeg)))
     (if (equal disk 1)
         (mod-chunk-fct 'm1 (list 'f c1 't frompeg)))
     (if (equal disk 1)
         (mod-chunk-fct 'm2 (list 'f c1 't (car pegs))))
     (mod-chunk-fct 'm3 (list 'd nil))
     (cond ((and (equal c1 c2) (not (equal c2 c3)))
            (mod-chunk-fct 'm3 (list 'd 3 'f c3 't (find-empty-peg))))
           ((and (equal c2 c3) (not (equal c1 c3)))
            (mod-chunk-fct 'm3 (list 'd 2 'f c2 't (find-empty-peg))))
           ((and (equal c1 c3) (not (equal c2 c3)))
            (mod-chunk-fct 'm3 (list 'd 2 'f c2 't (find-empty-peg))))
           ((and (not (equal c1 c3)) (not (equal c2 c3)) (not (equal c1 c2)))
            (mod-chunk-fct 'm3 (list 'd 2 'f c2 't c3)))
           )
     (loop (cond ((null states2) (return mfg2)))
           (if (equal (caar states2) tostate)
               (setf mfg2 (caaar (cdr (car states2)))))
           (setf states2 (cdr states2)))
     (if (> mfg2 (1- *fpathstart*))
         (setf *finalpath* 0)
         (setf *finalpath* (1+ *finalpath*)))
     (setf *moves* (1+ *moves*))
     (if (> (length (goal-stack)) 1)
         (update-goal))
     (if (not (find-empty-peg)) (setf *flatstates* (1+ *flatstates*)))
     )))

;; Updates the information on where disks are after a move has been made
;;  -Information available on the screen
(defun update-goal ()
  (let (curdisk)
    (setf curdisk (cond ((equal (get-slot-value (get-safe-wme (car (goal-stack))) 'disk) 1) 'd1)
                        ((equal (get-slot-value (get-safe-wme (car (goal-stack))) 'disk) 2) 'd2)
                        ((equal (get-slot-value (get-safe-wme (car (goal-stack))) 'disk) 3) 'd3)
                        (t (format t "I SCREWED UP AGAIN.   ~d" (dm (car (goal-stack)))))))
    (mod-chunk-fct (get-safe-wme (car (goal-stack))) 
                   (list 'c (get-slot-value (get-safe-wme curdisk) 'c) 'g (get-slot-value (get-safe-wme curdisk) 'g)))
    ))

;; Determines how many moves would be needed to correctly place the
;;  specified disk onto its goal peg
;;  -Used in determining which productions are applicable to the
;;   current problem state and subgoal
(defun moves-to-place-disk (disk)
  (no-output 
   (let ((usethisstate nil)
        (temp *states*)
        (state (liststate)))
    (loop (cond ((null temp) (return usethisstate)))
          (if (equal (caar temp) state) (setf usethisstate (cdr (car temp))))
          (setf temp (cdr temp)))
    (if (equal disk 2) (setf usethisstate (third usethisstate)) (setf usethisstate (second usethisstate)))
    (if (equal disk 1)
        (setf usethisstate (list '(1 1) (list (cons lftpeg (cdr state)) (cons lftpeg (cdr state))))) usethisstate)
    (if (equal state (list lftpeg midpeg ritpeg))
        (setf usethisstate (list '(-1 -1) (list (list lftpeg midpeg ritpeg) (list lftpeg midpeg ritpeg)))) usethisstate))))

;; Updates information when multiple moves are made
;;  -e.g., making 3 moves to place a disk
(defun do-moves (disk lis allow)
  (no-output
   (let ((mtpd (caar (moves-to-place-disk disk)))
         (newstate nil)
         (nummoves nil)
         (fromstate (liststate))
         (states1 *states*)
         (states2 *states*)
         (mfg1 0)
         (mfg2 0))
     (if (< (caar lis) allow)
         (setf newstate (caadr lis))
         (setf newstate (cadadr lis)))
     (if (< (caar lis) allow)
         (setf nummoves (caar lis))
         (setf nummoves (cadar lis)))
;     (format t "~d  ~d ~d  ~d~%" lis allow newstate nummoves)
     (loop (cond ((null states1) (return mfg1)))
           (if (equal (caar states1) fromstate)
               (setf mfg1 (caaar (cdr (car states1)))))
           (setf states1 (cdr states1)))
     (loop (cond ((null states2) (return mfg2)))
           (if (equal (caar states2) newstate)
               (setf mfg2 (caaar (cdr (car states2)))))
           (setf states2 (cdr states2)))
     (if (< mfg1 (1+ *fpathstart*))
         (setf *finalpath* (+ *finalpath* (1- nummoves)))
         (setf *finalpath* (- *fpathstart* (1+ mfg2))))
     (mod-chunk-fct 'd1 (list 'c (car newstate)))
     (mod-chunk-fct 'd2 (list 'c (car (cdr newstate))))
     (mod-chunk-fct 'd3 (list 'c (car (cddr newstate))))
     (setq *moves* (+ *moves* (1- nummoves)))
     (cond ((equal disk 1) (mod-chunk-fct (car (goal-stack)) (list 'c (car newstate))))
           ((equal disk 2) (mod-chunk-fct (car (goal-stack)) (list 'c (cadr newstate))))
           ((equal disk 3) (mod-chunk-fct (car (goal-stack)) (list 'c (caddr newstate))))
           (t (format t "SOMETHING IS NOT WORKING PROPERLY")))
     (if (equal (car newstate) (car (cdr newstate)))
         (move-disk 1 (car (cddr newstate)) (car newstate))
         (move-disk 1 (car (cdr newstate)) (car newstate)))
     (liststate)
     (if (and (equal allow 4)
              (or (equal mtpd 2)
                  (equal mtpd 4)))
         (move-disk 1 (car newstate) (find-empty-peg)))
;     (format t " ~d~%" nummoves)
     )))

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Model Code
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Initialization
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(clear-all)

(sgp :era t :er t :pl t :ans 2 :g 50 :blc 100 :rt 0.0)

(eval (list 'sgp ':egs *noise*))

(sgp :v nil :ct nil :lt nil :pct nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; The following are set to nil above.
;;
;; (sgp :v t)
;;   -Will print the model trace to the active listener
;;
;; (sgp :ct t)
;;   -Will print 
;;
;; (sgp :lt t)
;;   -Will print 
;;
;; (sgp :pct t)
;;   -Will print 
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Chunk-types and declarative memory
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(chunk-type disk size c g)
(chunk-type peg name)
(chunk-type place-disk disk c g strategy)
(chunk-type problem s1 s2 s3 g1 g2 g3 step)
(chunk-type move d f t)

(add-dm
   (d1 ISA disk size 1)
   (d2 ISA disk size 2)
   (d3 ISA disk size 3)
   (a ISA peg name a)
   (b ISA peg name b)
   (c ISA peg name c)
   (easy ISA problem s1 c s2 a s3 b g1 a g2 b g3 c step start)
   (hard ISA problem s1 b s2 c s3 a g1 a g2 b g3 c step start)
   (tran ISA problem s1 a s2 c s3 b g1 a g2 b g3 c step start)
   (m1 ISA move d 1)
   (m2 ISA move d 1)
   (m3 ISA move)
   (start ISA chunk)
   (end ISA chunk)
   (done ISA chunk))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Productions starting and finishing the problem and changing subgoals
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Encode the start state
(P read-disk
   =goal>
      ISA         problem
      step        start
==>
   =goal>
      step        0
   !eval!         (encode-state)
)

;; Set a subgoal to place the large disk in its goal state
(P start-subgoal-large
   =goal>
      ISA         problem
      step        0
   =disk>
      ISA         disk
      size        3
      c           =c
      g           =g
    - g           =c
==>
   =goal>
      step        end
   =place-disk>
      ISA         place-disk
      disk        3
      c           =c
      g           =g
      strategy    start
   !push!         =place-disk
)

;; When a disk is correctly placed, make the subgoal to place
;;  the largest disk that is still out of place
;;  -This is where the productions discussed in the paper are
;;   updated during the problem
(P new-disk
   =goal>
      ISA         place-disk
      disk        =size
   -  disk        1
      c           =g
      g           =g
      strategy    =strategy
   =disk>
      ISA         disk
    - size        =size
      size        =next
    - size        1
      c           =cur
    - c           =g
      g           =g2
    - g           =cur
   =smalldisk>
      ISA         disk
      size        1
    - c           =g
==>
   =place-next-disk>
      ISA         place-disk
      disk        =next
      c           =cur
      g           =g2
      strategy    =strategy
   !focus-on!     =place-next-disk
)

;; If the small disk is the only one out of place,
;;  then move it to its goal state
(P last-move
   =goal>
      ISA         place-disk
      disk        =size
      c           =g
      g           =g
   =disk>
      ISA         disk
    - size        =size
      size        =next
    - size        1
      c           =cur
      g           =cur
   =small>
      ISA         disk
      size        1
      c           =now
      g           =fin
    - g           =now
==>
   !eval!         (move-disk 1 =now =fin)
)

;; Problem solved; productions are also updated here.
(P done-problem
   =goal>
      ISA         place-disk
      disk        =size
      c           =g
      g           =g
   !eval!         (and (equal (caar (moves-to-place-disk 1)) -1)
                       (equal (caar (moves-to-place-disk 2)) -1)
                       (equal (caar (moves-to-place-disk 3)) -1))
==>
   =goal>
      disk        nil
      c           nil
      g           nil
   !pop!
)

;; Pops the top-level goal when the problem is solved
(P done-finish
   =goal>
      ISA         problem
      step        end
==>
   =goal>
      step        done
   !pop!
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Productions for solving the problem
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Random - No planning
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(P random-move
   =goal>
      ISA         place-disk
      disk        =size
      c           =c
      g           =g
      strategy    start
   =move>
      ISA         move
      d           =s
      f           =f
      t           =t
==>
   !eval!         (move-disk =s =f =t)
;   !eval!         (format t "Random Move                 ~d ~d ~d~%" =s =f =t)
   )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Productions for optimal planning
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(P place-disk-in-one
   =goal>
      ISA         place-disk
      disk        =size
    - disk        1
      c           =c
      g           =g
      strategy    start
   !eval!         (= (caar (moves-to-place-disk =size)) 1)
==>
;   !eval!         (format t "Placing disk ~d with 1 or fewer moves ~d ~d~%" =size =c =g)
   !eval!         (do-moves =size (moves-to-place-disk =size) 2)              
   )

(P place-disk-in-two
   =goal>
      ISA         place-disk
      disk        =size
    - disk        1
      c           =c
      g           =g
      strategy    start
   !eval!         (= (caar (moves-to-place-disk =size)) 2)
==>
;   !eval!         (format t "Placing disk ~d with 2 or fewer moves ~d ~d~%" =size =c =g)
   !eval!         (do-moves =size (moves-to-place-disk =size) 3)              
   )

(P place-disk-in-three
   =goal>
      ISA         place-disk
      disk        =size
    - disk        1
      c           =c
      g           =g
      strategy    start
   !eval!         (= (caar (moves-to-place-disk =size)) 3)
==>
;   !eval!         (format t "Placing disk ~d with 3 or fewer moves ~d ~d~%" =size =c =g)
   !eval!         (do-moves =size (moves-to-place-disk =size) 4)              
   )

(P place-disk-in-four
   =goal>
      ISA         place-disk
      disk        =size
    - disk        1
      c           =c
      g           =g
      strategy    start
   !eval!         (= (caar (moves-to-place-disk =size)) 4)
==>
;   !eval!         (format t "Placing disk ~d with 4 or fewer moves ~d ~d~%" =size =c =g)
   !eval!         (do-moves =size (moves-to-place-disk =size) 5)              
   )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Flat-to-flat productions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(P move-to-flat
   =goal>
      ISA         place-disk
      disk        =size
      c           =c
      g           =g
    - disk        1
      strategy    start
   !eval!         (find-empty-peg)
   !eval!         (not (and (equal (get-slot-value (get-safe-wme 'd1) 'c)
                                   (get-slot-value (get-safe-wme 'd2) 'c))
                            (equal (get-slot-value (get-safe-wme 'd2) 'c)
                                   (get-slot-value (get-safe-wme 'd3) 'c))))
==>
;   !eval!         (format t "Move to Flat State  ~d  1 ~d ~d~%" (liststate) =c =t)
   !eval!         (move-disk 1 (get-slot-value (get-safe-wme 'd1) 'c) (find-empty-peg))
   
)

(P flat-to-flat-clear
   =goal>
     ISA         place-disk
     disk        =s
   - disk        1
     c           =c
     g           =g
;   - c           =g
   !eval!        (and (not (equal (get-slot-value (get-safe-wme 'd1) 'c) (get-slot-value (get-safe-wme 'd2) 'c)))
                      (not (equal (get-slot-value (get-safe-wme 'd2) 'c) (get-slot-value (get-safe-wme 'd3) 'c)))
                      (not (equal (get-slot-value (get-safe-wme 'd1) 'c) (get-slot-value (get-safe-wme 'd3) 'c)))
                      (= (caar (moves-to-place-disk =s)) 4))
==>
;   !eval!         (format t "Clearing peg for disk ~d with a flat-to-flat transformation ~d ~d~%" =size =c =sc)
   =goal>
     strategy    t
   !eval!         (do-moves =s (moves-to-place-disk =s) 4)
   
)

(P flat-to-flat-place
   =goal>
     ISA         place-disk
     disk        =s
   - disk        1
     c           =c
     g           =g
;   - c           =g
   !eval!        (and (not (equal (get-slot-value (get-safe-wme 'd1) 'c) (get-slot-value (get-safe-wme 'd2) 'c)))
                      (not (equal (get-slot-value (get-safe-wme 'd2) 'c) (get-slot-value (get-safe-wme 'd3) 'c)))
                      (not (equal (get-slot-value (get-safe-wme 'd1) 'c) (get-slot-value (get-safe-wme 'd3) 'c)))
                      (no-output (equal (get-slot-value (get-safe-wme 'd1) 'c) (get-slot-value (get-safe-wme (goal-focus)) 'g))))
==>
;   !eval!         (format t "Placing disk ~d with a flat-to-flat transformation ~d ~d~%" =size =c =sc)
   !eval!         (do-moves =s (moves-to-place-disk =s) 4)
   
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Production Parameters
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;Random Move (No Planning)
(eval (list 'spp 'RANDOM-MOVE         ':EFFORTS (* *random-history* (+ 6.25 *scale*)) ':SUCCESSES *random-history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *random-history* ':EFFORT *move-time*))

;Place Disk Strategies
(eval (list 'spp 'PLACE-DISK-IN-ONE   ':EFFORTS (* *history* (+ 6.25 (* *scale* 1)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 1)))
(eval (list 'spp 'PLACE-DISK-IN-TWO   ':EFFORTS (* *history* (+ 6.25 (* *scale* 2)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 2)))
(eval (list 'spp 'PLACE-DISK-IN-THREE ':EFFORTS (* *history* (+ 6.25 (* *scale* 3)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 3)))
(eval (list 'spp 'PLACE-DISK-IN-FOUR  ':EFFORTS (* *history* (+ 6.25 (* *scale* 4)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 4)))


;flat strategies
(eval (list 'spp 'MOVE-TO-FLAT        ':EFFORTS (* *history* (+ 6.25 (* *scale* 1)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 1)))
(eval (list 'spp 'FLAT-TO-FLAT-PLACE  ':EFFORTS (* *history* (+ 6.25 (* *scale* 3)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 3)))
(eval (list 'spp 'FLAT-TO-FLAT-CLEAR  ':EFFORTS (* *history* (+ 6.25 (* *scale* 3)))  ':SUCCESSES *history* ':EVENTUAL-EFFORTS 0.1 ':EVENTUAL-SUCCESSES *history* ':EFFORT (* *move-time* 3)))

(spp START-SUBGOAL-LARGE     :EFFORTS     1 :SUCCESSES 1000000  :EVENTUAL-EFFORTS  1000000  :EVENTUAL-SUCCESSES  100000000)
(spp READ-DISK    :SUCCESSES 1000000 :EVENTUAL-SUCCESSES 1000000)
(spp NEW-DISK     :SUCCESSES 1000000 :EVENTUAL-SUCCESSES 1000000 :STRENGTH 100)
(spp LAST-MOVE    :SUCCESSES 1000000 :EVENTUAL-SUCCESSES 1000000 :STRENGTH 100 :EFFORT 1.5)
(spp DONE-PROBLEM :SUCCESSES 1000000 :EVENTUAL-SUCCESSES 1000000 :STRENGTH 100)
(spp DONE-FINISH  :SUCCESSES 1000000 :EVENTUAL-SUCCESSES 1000000 :STRENGTH 100)
;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Initializes the goal to an easy problem

(goal-focus easy)

;; Calls the function to create *states*
(setstates)

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