Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define runaway-strategy
- (lambda (gh g)
- (letrec ((p (game-pacman g))
- (c (ghost-col gh))
- (r (ghost-row gh))
- (dir (ghost-dir gh))
- (d-up (distance p c (- r 1)))
- (d-down (distance p c (+ r 1)))
- (d-left (distance p r (- c 1)))
- (d-right (distance p r (+ c 1)))
- (crossing-code (direction-map/coordinate
- (maze-direction-map
- (field-maze
- (game-field g)))
- c r))
- (poss-dirs (code->direction crossing-code))
- (distances (map (lambda (x)
- (cond ((string=? "up" x) d-up)
- ((string=? "down" x) d-down)
- ((string=? "left" x) d-left)
- ((string=? "right" x) d-right))) poss-dirs))
- (maxdist (fold 0 max distances)))
- (cond
- ((= maxdist 0) dir)
- ((and (any? (lambda (x) (direction=? "down" x)) poss-dirs) (= d-down maxdist)) "down")
- ((and (any? (lambda (x) (direction=? "up" x)) poss-dirs) (= d-up maxdist)) "up")
- ((and (any? (lambda (x) (direction=? "left" x)) poss-dirs) (= d-left maxdist)) "left")
- ((and (any? (lambda (x) (direction=? "right" x)) poss-dirs) (= d-right maxdist)) "right")))))
Add Comment
Please, Sign In to add comment