+2 votes
in Artificial Intelligence by

Implement a performance-measuring environment simulator for the vacuum-cleaner world depicted in Figure 2.2 and specified on page 38. Your implementation should be modular so that the sensors, actuators, and environment characteristics (size, shape, dirt placement, etc.) can be changed easily. (Note: for some choices of programming language and operating system there are already implementations in the online code repository.)


1 Answer

+1 vote
selected by (user.guest)
Best answer
In the case of performance measure of a vacuum cleaner, test the amount of dirt cleaned, the amount of time taken to clean, the amount of electricity consumed, and the amount of noise generated. The environment is the agent’s design. It has three characteristics – size, shape, and dirt placement. It is easy to change dirt placement and choose the size of the brush, experiment by changing the shape, size, and dirt placement.
The vacuum world-cleaning up the dirt in grid: Implementation in Lisp

;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*-

;;;; The Vacuum World: cleaning up dirt in a grid

(defstructure (dirt (:include object (name "*")

(size 0.001))))

(defstructure (vacuum-world (:include grid-environment

(size (@ 7 7))

(aspec '(random-vacuum-agent))

(cspec '((at all (P 0.25 dirt))))))

"A grid with some dirt in it, and by default a reactive vacuum agent.")

;;;; Defining the generic functions

(defmethod performance-measure ((env vacuum-world) agent)

"100 points for each piece of dirt vacuumed up, -1 point for each step taken, and -1000 points if the agent does not return home."

(- (* 100 (count-if #'dirt-p (object-contents (agent-body agent))))

(environment-step env)

(if (equal (object-loc (agent-body agent))

(Grid-environment-start env))



(defmethod get-percept ((env vacuum-world) agent)

"Percept is a three-element sequence: bump, dirt and home."

(let ((loc (object-loc (agent-body agent))))

(list (if (object-bump (agent-body agent)) 'bump)

(if (find-object-if #'dirt-p loc env) 'dirt)

(if (equal loc (grid-environment-start env)) 'home))))

(defmethod legal-actions ((env vacuum-world))

'(suck forward turn shut-off))

;;;; Actions (other than the basic grid actions of forward and turn)

(defmethod suck ((env vacuum-world) agent-body)

(let ((dirt (find-object-if #'dirt-p (object-loc agent-

body) env)))

(when dirt(place-in-container dirt agent-body env))))

(defmethod shut-off ((env environment) agent-body)

(declare-ignore env)setf (object-alive? agent-body) nil))
Variables used:

• dirt

• vacuum-world


• performance-measure

• get-percept

• legal-actions


• suck method

• shut-off method

Related questions

+1 vote
1 answer 349 views
+1 vote
1 answer 1.8k views
+1 vote
1 answer 829 views
+1 vote
1 answer 78 views
+2 votes
2 answers 175 views
+2 votes
1 answer 522 views
+1 vote
1 answer 23 views
+1 vote
1 answer 41 views
Welcome to CPENTalk.com
Solution-oriented students of computer engineering on one platform to get you that