#lang racket
(require "engine.rkt")
(provide move-robot-default)
(define (move-robot-default r d)
(let* ([x (random 100)]
[danger? (lambda (x) (or (bomb? x) (fire? x)))]
[something? (lambda (x) #t)]
[escape (lambda (r d)
(cond [(not (empty? (sprite-left r danger? d))) (go-right r d)]
[(not (empty? (sprite-right r danger? d))) (go-left r d)]
[(not (empty? (sprite-up r danger? d))) (go-down r d)]
[(not (empty? (sprite-down r danger? d))) (go-up r d)]
[(not (empty? (search-sprite (sprite-x r) (sprite-y r) bomb? d)))
(cond [(empty? (sprite-left r something? d)) (go-left r d)]
[(empty? (sprite-right r something? d)) (go-right r d)]
[(empty? (sprite-up r something? d)) (go-up r d)]
[(empty? (sprite-down r something? d)) (go-down r d)]
[else d])]))])
(if (empty? r)
d
(cond
[(or (not (empty? (sprite-left r danger? d)))
(not (empty? (sprite-right r danger? d)))
(not (empty? (search-sprite (sprite-x r) (sprite-y r) bomb? d))))
(if (empty? (sprite-up r something? d))
(go-up r d)
(if (empty? (sprite-down r something? d))
(go-down r d)
(escape r d)))]
[(or (not (empty? (sprite-up r danger? d)))
(not (empty? (sprite-down r danger? d)))
(not (empty? (search-sprite (sprite-x r) (sprite-y r) bomb? d))))
(if (empty? (sprite-left r something? d))
(go-left r d)
(if (empty? (sprite-right r something? d))
(go-right r d)
(escape r d)))]
[(and (> x 0) (<= x 10) (empty? (sprite-up r fire? d))) (go-up r d)]
[(and (> x 10) (<= x 20) (empty? (sprite-down r fire? d))) (go-down r d)]
[(and (> x 20) (<= x 30) (empty? (sprite-left r fire? d))) (go-left r d)]
[(and (> x 30) (<= x 40) (empty? (sprite-right r fire? d))) (go-right r d)]
[(and (> x 40) (<= x 42) (not (blocked? r d))) (drop-bomb r d)]
[else d]))))