summaryrefslogtreecommitdiff
path: root/scheme/simple.scm
diff options
context:
space:
mode:
Diffstat (limited to 'scheme/simple.scm')
-rw-r--r--scheme/simple.scm32
1 files changed, 32 insertions, 0 deletions
diff --git a/scheme/simple.scm b/scheme/simple.scm
new file mode 100644
index 0000000..66f3591
--- /dev/null
+++ b/scheme/simple.scm
@@ -0,0 +1,32 @@
+;;; simple.scm
+;;; Sample robot provided by Jim Hall <jhall1@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)