;;;;;;;;;;SCI-RULES.L By Brian Cole ;;;;;;;;;;High School Computing Institute 1997 ;;;;;;;;;;West Jordan High ;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; File: sci-rules.l ; Description: Set of rules of sample SCI cassini rover ; Author: Robert R. Kessler & Patrick Dalton ; Created: 27-Aug-92 ; ; (c) Copyright 1992, University of Utah, all rights reserved. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Magic Incantations ;;; (eval-when (compile load eval) (in-package :cole) (require "frobs") (require "cassini")) (eval-when (compile load eval) (use-package "FROBS") (shadowing-import 'cassini::collect) (use-package "CASSINI")) (eval-when (compile) (load "/home/cs/other/hsci/accounts/bcole/cole/sci-frobs")) (eval-when (load eval) (load "/home/cs/other/hsci/accounts/bcole/cole/sci-interface")) ;;; ;;; To handle appropriate firing of the rules, the state slot is the one that ;;; will be asserted to get the system going. So, it is imperative that all ;;; rules include access to the state slot. For the very first call to the ;;; rule system, the state slot will be set to 'initialize. Once the rules ;;; decide which state they want next, they should set the next-state slot to ;;; that value. The interface code will make state be next-state and ;;; next-state be nil on the next calling sequence. ;;; ;;; The function add-action-to-front will take a rover object and a command and ;;; add it to the beginning of the list of actions. The function ;;; add-action-to-end will do the same thing, but add it to the end of the ;;; actions list. This is useful if you want multiple rules to fire and decide ;;; to do lots of things during a turn. ;;; ;;; All rules should be of the form (filling in the things between the <..> ;;; with something meaningful). ;;; ;;; (def-rule ;;; :type ((?rover sci-rover)) ;;; :local (?) ;;; :prem ((state ?rover ) ;;; (...)) ;;; :cons (progn ;;; (assert-val ?rover 'next-actions ) ;;; (assert-val ?rover 'next-state )) ;;; ;;; Many rules will also include (next-actions ?rover nil) to keep too many ;;; rules from firing and all deciding what to do next. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def-rule initialize-rover :type ((?rover sci-rover)) :prem ((state ?rover initialize)) :conc (progn (assert-val ?rover 'next-actions '((look))) (assert-val ?rover 'next-state 'look-around))) ;;; ;;; Movement and return home rules. Use the move-or-go-home state as a ;;; trigger. ;;; (def-rule go-home :type ((?rover sci-rover)) :local (?fuel ?home) :prem ((state ?rover move-or-go-home) (fuel-remaining ?rover ?fuel) (fuel-to-go-home ?rover ?home) (evalp (and (not (equal ?home :unknown)) (< ?fuel (+ ?home 2.8)))) (at-home-p ?rover nil) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((go-home))) (assert-val ?rover 'next-state 'deliver))) (def-rule move-north :type ((?rover sci-rover)) :local (?terrain ?safe) :prem ((state ?rover move-or-go-home) (north ?rover ?terrain) (safe-interfaces ?rover ?safe) (evalp (member ?terrain ?safe)) (north-visits ?rover 0) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((move :north))) (assert-val ?rover 'next-state 'look-around))) (def-rule move-south :type ((?rover sci-rover)) :local (?terrain ?safe) :prem ((state ?rover move-or-go-home) (south ?rover ?terrain) (safe-interfaces ?rover ?safe) (evalp (member ?terrain ?safe)) (south-visits ?rover 0) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((move :south))) (assert-val ?rover 'next-state 'look-around))) (def-rule move-east :type ((?rover sci-rover)) :local (?terrain ?safe) :prem ((state ?rover move-or-go-home) (east ?rover ?terrain) (safe-interfaces ?rover ?safe) (evalp (member ?terrain ?safe)) (east-visits ?rover 0) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((move :east))) (assert-val ?rover 'next-state 'look-around))) (def-rule move-west :type ((?rover sci-rover)) :local (?terrain ?safe) :prem ((state ?rover move-or-go-home) (west ?rover ?terrain) (safe-interfaces ?rover ?safe) (evalp (member ?terrain ?safe)) (west-visits ?rover 0) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((move :west))) (assert-val ?rover 'next-state 'look-around))) (def-rule move-someplace :type ((?rover sci-rover)) :local () :prem ((state ?rover move-or-go-home) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions (list (list 'move (best-random-direction ?rover)))) (assert-val ?rover 'next-state 'look-around) )) ;;; ;;; Fill in code for movement in the various other directions. ;;; ;;; Enhance your code to be smart about movement, possibly using the number of ;;; visits in the various directions. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; If we are at the base, then we should deliver our goods and recharge our ;;; battery. This assumes that we are in state deliver. ;;; (def-rule at-base :type ((?rover sci-rover)) :prem ((state ?rover deliver) (at-home-p ?rover t) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((deliver) (recharge-battery))) (assert-val ?rover 'next-state 'move-or-go-home))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Ok, if we are in the look around state, then we should do just that. ;;; ;;; This is the action sequence in a new square: when we can't see, all of the ;;; directions will be unknown, so let's turn on our lights, do a look, and ;;; then turn them off again. ;;; (def-rule look-around :type ((?rover sci-rover)) :local (?vis-es) :prem ((state ?rover look-around) (north ?rover :unknown) (vis-emit-p ?rover nil) (vis-es ?rover ?vis-es) (evalp (> ?vis-es 0)) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'next-actions '((emitter-on :vis) (look) (emitter-off :vis))) (assert-val ?rover 'next-state 'grab-objects))) (def-rule switch-to-grab :type ((?rover sci-rover)) :local (?terrain) :prem ((state ?rover look-around) (north ?rover ?terrain) (evalp (not (equal ?terrain :unknown))) (next-actions ?rover nil)) :conc (progn (assert-val ?rover 'state 'grab-objects))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; We are in the state to grab some objects that are interesting. ;;; (def-rule melt-snow-bank :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :white) (size ?thing :large) (shape ?thing :mound) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'emitter-off :uv)) (add-action-to-front ?rover (list 'emitter-on :uv )) (assert-val ?rover 'next-state 'grab-objects))) (def-rule tweak-chest :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :brown) (size ?thing :large) (shape ?thing :rectangular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'tweak ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-empty-chest :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :brown) (size ?thing :large) (shape ?thing :rectangular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-sponge :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow-brown) (size ?thing :medium) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-sponge :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow-brown) (size ?thing :medium) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-topaz :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow-brown) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-gold-nugget :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow) (size ?thing :medium) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-autunite :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow) (size ?thing :small) (other ?thing :low-xray) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule zap-life-form-y37 :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow) (size ?thing :medium) (shape ?thing :irregular) (glow-color ?thing :flouresces-blue) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'zap ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-dead-life-form-y37 :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow) (size ?thing :medium) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-rolex :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow) (size ?thing :small) (shape ?thing :circular) (sound ?thing :sound-tick-tick) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-tripe-ration :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :white) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-sun-flower :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :white) (size ?thing :large) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-frozen-gleekzorp :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :white) (size ?thing :small) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule tweak-doorknob :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :silver) (size ?thing :small) (shape ?thing :spherical) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'tweak ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-amethyst :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :violet) (size ?thing :small) (glow-color ?thing :fluoresces-yellow) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-quarter :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :silver) (size ?thing :small) (shape ?thing :circular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-alien-record :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :silver) (size ?thing :small) (shape ?thing :circular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-polonium :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :red) (size ?thing :small) (other ?thing :high-xray) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-ruby :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :red) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-small-mirror :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :nasa-gray) (size ?thing :medium) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-torbernite :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (other ?thing :low-xray) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-nuclear-pwd-plant :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :green) (size ?thing :small) (other ?thing :low-xray) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-emerald :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :green) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-acid-blob :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :green) (size ?thing :medium) (shape ?thing :globular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-oxygen-bottle :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :green) (size ?thing :medium) (shape ?thing :cylindrical) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-plutonium :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :gray) (other ?thing :high-xray) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule zap-snake :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :gray) (size ?thing :small) (shape ?thing :cylindrical-irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'zap ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-dead-snake :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :gray) (size ?thing :small) (shape ?thing :cylindrical-irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-opal :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :flashy) (size ?thing :small) (glow-color ?thing :fluoresces-green) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-full-coke-bottle :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :brown) (size ?thing :small) (shape ?thing :cylindrical-tapered) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-sapphire :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :blue-violet) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-bomb :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :small) (shape ?thing :spherical) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-glow-bush :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :small) (other ?thing :high-xray) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-bush :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :small) (glow-color ?thing :glows-yellow) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-small-monolith :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :small) (shape ?thing :rectangular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-life-form-x42 :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :medium) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-dead-life-form-x42 :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :medium) (shape ?thing :irregular) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-battery :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :black) (size ?thing :small) (shape ?thing :cylindrical) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-gold :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :yellow) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule get-diamonds :type ((?rover sci-rover) (?thing sci-object)) :local (?id) :mv (visible-objects) :prem ((state ?rover grab-objects) (visible-objects ?rover ?thing) (color ?thing :transparent) (size ?thing :small) (id ?thing ?id)) :conc (progn (add-action-to-front ?rover (list 'collect ?id)) (assert-val ?rover 'next-state 'move-or-go-home))) (def-rule nothing-I-want :type ((?rover sci-rover)) :prem ((state ?rover grab-objects) (next-actions ?rover nil)) :conc (assert-val ?rover 'state 'move-or-go-home)) (def-rule nothing-to-get :type ((?rover sci-rover)) :prem ((state ?rover grab-objects) (visible-objects ?rover nil)) :conc (progn (assert-val ?rover 'state 'move-or-go-home))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; End of file.