File: zap.scm

package info (click to toggle)
gnurobots 2%3A1.1.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,864 kB
  • ctags: 376
  • sloc: sh: 9,120; ansic: 2,579; lisp: 552; makefile: 116
file content (36 lines) | stat: -rw-r--r-- 871 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;;; zap.scm
;;; Sample robot provided by Jim Hall <jhall1@isd.net>
;;; This is an agressive little robot that will just turn 360-degrees,
;;; and will immediately zap anything that isn't a space.  This builds
;;; on the beep.scm robot program, so it will also beep if it finds a
;;; prize (but then destroys it.)

;;; Define a function to make a beep
(define (beep) (display "\a"))

;;; Define a function to blow away anything that isn't a space
(define (blast-nonspace)
  (if (robot-feel "space") (robot-zap)))

;;; Define a function to turn, then see if a prize is there
(define (turn-and-feel)
  (robot-turn 1)
  (if (robot-feel "prize") (beep)))

;;; The program begins here: make one sweep

(turn-and-feel)
(blast-nonspace)
(sleep 1)

(turn-and-feel)
(blast-nonspace)
(sleep 1)

(turn-and-feel)
(blast-nonspace)
(sleep 1)

(turn-and-feel)
(blast-nonspace)
(sleep 1)