;;; THE INTRO TO AI SHOW ;;; Summer Session I 1999 ;;; ;;; DEMO: ;;; A simple reflex agent from Figure 2.8 in AIMA text ;;; ;;; Note: This demo makes indiscriminate use of special ;;; variables. It is intended to be a quick and dirty ;;; instantiation of a simple reflex agent. What assumptions are made ;;; about Willard's environment given the use of special variables ;;; herein? ;;; ;;; Selmer Bringsjord ;;; The initial state. (defvar *state* 'hailing) ;;; The set of invariant condition-action rules. (defvar *rules* '((raining get-umbrella) (snowing get-dynastars) (sunning get-burner-bubble) (freezing get-prince-raquet) (hailing get-inside))) ;;; The mapping from scene snapshots to states. (defvar *percept->state* '((snapshot1 raining) (snapshot2 snowing) (snapshot3 freezing) (snapshot4 sunning) (snapshot5 hailing))) (defun willard (p) "The agent Willard. Percept in, action back." (setf *state* (interpret-input p)) (rule-match *state*)) (defun rule-match (state) "Takes a weather state and returns an appropriate action." (let ((result-rule nil)) (dolist (rule *rules* result-rule) (when (eql state (first rule)) (setf result-rule (second rule)))))) (defun interpret-input (snapshot) "Takes a snapshot, a visual scene, and returns a metereological condition." (let ((result-rule nil)) (dolist (rule *percept->state* result-rule) (when (eql snapshot (first rule)) (setf result-rule (second rule))))))