
;; this file contains code for use in problem set 2 on strategies for guessing numbers

;; procedure for choosing nearest integer
(define flip
   (lambda (n)
     (cond ((integer? n) n)
           ((= (random 2) 1) (floor n))
           (else (ceiling n)))))

;; Louis' first attempt

(define strategy-random
  (lambda ()
    (define helper                             ; internal helper procedure
      (lambda (n)                              ; argument is no. of trials
        (if (=-hidden (+ low-limit
                         (random (+ (- high-limit low-limit)
                                 1))))         ; to get random number in range
                                               ; have found right number
            n                                  ; return no. of trials
            (helper (+ n 1)))))                ; else do again with new guess
    (helper 1)))                               ; start off with first try

;; you need to complete the procedure below for general strategies

(define general-strategy
  (lambda (next-guess next-lub next-glb trial guess lub glb)
    (if (=-hidden guess)
        trial
        (general-strategy
        ;; need to complete this
              ))))


(define tester
  (lambda (no-of-trials strategy type)
    (define final-stats (make-statistic type))
    (define updater (make-updater type))
    (define run-it
      (lambda (n stat)
        (if (= n no-of-trials)
            ;; fill in here
            (sequence (setup 1 1000)
                      ;; fill in here
                  ))))
    (run-it 0 0)))
