Example GNU Robots program

477 views
Skip to first unread message

Duncan Bayne

unread,
Feb 18, 2011, 2:05:47 AM2/18/11
to grc-melbourne
Here's a very simple GNU Robots program to give you an idea of what's
involved. It's one of the sample programs that is installed along
with GNU Robots.

Note that on many maps, this terminates with a score of 0; I would
expect something a lot more fiendish to win on the night :-)


;;; simple.scm
;;; Sample robot provided by Jim Hall <jha...@isd.net>
;;; This robot will simply hunt down and grab any prizes in its direct
;;; line of sight. If it runs into an obstacle, it turns right and
;;; continues from there. When it has turned 360-degrees, it stops.

;;; Define a function to feel for prize (wrapper)
(define (feel-prize)
(robot-feel "prize"))

;;; Define a function to grab a single prize
(define (grab-prize)
(robot-grab)
(robot-move 1))

;;; Define a function to grab all prizes
(define (grab-all-prizes)
(do () (not (feel-prize)) (grab-prize)))

;;; The program starts here: hunt for all prizes

(grab-all-prizes)
(robot-turn 1)

(grab-all-prizes)
(robot-turn 1)

(grab-all-prizes)
(robot-turn 1)

(grab-all-prizes)
(sleep 1)
Reply all
Reply to author
Forward
0 new messages