1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- (import
- (scheme base)
- (scheme read)
- (scheme write)
- (scheme load)
- (srfi 27)
- (yasos)
- ;; (macduffie alsos)
- (turtle turtle3)
- (turtle vector))
- (include "./animal.scm")
- (define (make-prey starting-pos)
- (define t (make-hungry-turtle))
- (hide! t)
- (pen-up! t)
- (set-pos! t starting-pos)
- (pen-down! t)
- (show! t)
- (set-food! t (lambda (turt) #(-20 -20)))
- ; (set-strategy! t (make-strategy-random 5 10 -10 5))
- ; (set-strategy! t (make-strategy-smell-3 2 6 20 10))
- ; (set-strategy! t (make-strategy-circle 10 20))
- (set-strategy! t (make-strategy-direct 10))
- t)
- (define (make-predator starting-pos the-prey)
- (define t (make-hungry-turtle))
- (hide! t)
- (pen-up! t)
- (set-pos! t starting-pos)
- (pen-down! t)
- (show! t)
- (set-food! t (lambda (turt) (get-pos the-prey)))
- (set-strategy! t (make-strategy-smell-3 2 6 20 10))
- t)
- (define max-delta 200)
- (define (execute-together pred-proc prey-proc)
- (let loop ((i 0))
- (when (< i max-delta)
- (pred-proc)
- (prey-proc)
- (loop (+ i 1)))))
- (define (main)
- (define t1 (make-prey #(100 100)))
- (define t2 (make-predator #(-50 -50) t1))
- (clear-screen)
- (execute-together
- (lambda () (step! t1 1 1))
- (lambda () (step! t2 3 1))))
|