(defun csl (x y sd) (let ((lookup #2A((5.e-5 2.07e-4) (9.4e-5 4.14e-4) (1.35e-4 6.21e-4) (1.75e-4 8.27e-4) (2.14e-4 0.001033) (2.51e-4 0.00124) (2.88e-4 0.001446) (3.23e-4 0.001652) (3.58e-4 0.001858) (3.92e-4 0.002064) (4.25e-4 0.002269) (4.57e-4 0.002475) (4.89e-4 0.002681) (5.21e-4 0.002887) (5.52e-4 0.003092) (5.82e-4 0.003298) (6.12e-4 0.003504) (6.41e-4 0.003709) (6.7e-4 0.003915) (6.98e-4 0.00412) (7.26e-4 0.004326) (7.54e-4 0.004531) (7.81e-4 0.004737) (8.07e-4 0.004943) (8.34e-4 0.005148))) (ridist #1A(2/4269 17/4269 1/1423 2/4269 65/4269 4075/4269 31/1423 11/4269 1/4269)) ;;ridist indexed st 0=1.47 ;;each additional inde increments by .01 (sddist #1A(169/2128 477/2128 235/1064 43/266 473/4256 303/4256 25/532 4/133 79/4256 3/266 9/1064 17/4256 5/1064 13/4256 1/608 5/4256 1/2128 1/4256 1/2128 0 0 1/4256 0 1/4256)) ;;sddist starts at sd=1, goes to sd=25 (diff (abs (- y x))) (sd.to.ng nil) (sd.to.g nil) (avg.ri 0) (curr 0) (rival 0) (sdval 0) (best 0) (best.sol ())) (dotimes (i (array-dimension lookup 0)) (if (and (< diff (aref lookup i 0)) (eql nil sd.to.g)) (setf sd.to.g (+ i 1))) (if (and (> diff (aref lookup i 1)) (eql nil sd.to.ng)) (setf sd.to.ng (+ i 1)))) (cond ((<= diff (aref lookup (- sd 1) 0)) (format t "GUILTY!~%") (if (eql nil sd.to.ng) (format t "To be innocent,increase distance between x and y by:~A~%" (- (aref lookup (- sd 1) 1) diff)) (progn ;(format t "Alternatively, you could change your sd to: ~A~%" sd.to.ng) (dotimes (i (- sd sd.to.ng)) (setf avg.ri (floor (* 100 (/ (+ x y (- (aref lookup (+ sd.to.ng i -1) 1) diff)) 2)))) (if (<= 147 (- avg.ri 147) 155) (setf rival (aref ridist (- avg.ri 147))) (setf rival 0)) (if (<= 1 (+ sd.to.ng i 1) 25) (setf sdval (aref sddist (+ sd.to.ng i 1))) (setf sdval 0)) (setf curr (+ rival sdval)) (if (> curr best) (progn (setf best curr) (setf best.sol (list (- (aref lookup (+ sd.to.ng i -1) 1) diff) (+ sd.to.ng i 1))) ;(print 'best!) ))) (format t "Change distance by ~A and change sd to ~A.~%" (first best.sol) (second best.sol))))) ((> diff (aref lookup (- sd 1) 0)) (format t "NOT GUILTY!~%") ;(format t "possible ~A~%" sd.to.g) (if (eql nil sd.to.g) (format t "To be guilty,decrease distance between x and y by :~A~%" (- diff (aref lookup (- sd 1) 0))) (progn ;;(format t "Alternatively, you could change your sd to: ~A~%" sd.to.g) ;(format t "To be guilty,decrease distance between x and y by :~A~%" (- diff (aref lookup (- sd 1) 0))) ;(print (- sd 1)) (dotimes (i (+ (- sd.to.g sd) 1)) ;(format t "testing ~A~%" (+ sd i -1)) ;(format t "diff is ~A innocence is is ~A~%" diff (aref lookup (+ sd i -1) 0)) (setf avg.ri (floor (* 100 (/ (+ x y (- diff (aref lookup (+ sd i -1) 0))) 2)))) (if (<= 147 (- avg.ri 147) 155) (setf rival (aref ridist (- avg.ri 147))) (setf rival 0)) (if (<= 1 (+ sd i -1) 25) (setf sdval (aref sddist (+ sd i 0))) (setf sdval 0)) (setf curr (+ rival sdval)) (if (> curr best) (progn (setf best curr) (setf best.sol (list (- diff (aref lookup (+ sd i -1) 0)) (+ sd i))) ;;(print 'best!) ))) (format t "To be guilty, decrease distance by ~A and change sd to ~A.~%" (first best.sol) (second best.sol)))))) 'done)) (defun demo1 () (csl 1.4 (- 1.4003 1.205e-5) 8)) (defun demo2 () (csl 1.4 1.4 5)) (defun demo3 () (csl 1.5 1.51 9))