#1 Download computer science & engineering books free           #2 Display your sponsored posts here. Reach 20,000+ students. Contact: info[at]cpentalk.com for quote           #3 Take the Ultimate Trivia Quiz. See where you rank globally.
+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

Welcome to CPEN Talk
Solution-oriented students of computer engineering on one platform to get you that


Chuck Norris breaks RSA 128-bit encrypted codes in milliseconds.