Skip to content
Textbook Guides

Solution Manual For Artificial Intelligence: A Modern Approach, 3rd Edition

Get ahead in your studies with Solution Manual For Artificial Intelligence: A Modern Approach, 3rd Edition, offering the solutions and explanations needed to understand your textbook.

Preview 16 of 234 pages

See the first 16 pages exactly as they appear in the document.

  1. Page 1
    Read page 1 as text

    Exercise Solutions for Artificial Intelligence A Modern Approach Third Edition (International Version) Stuart J. Russell and Peter Norvig with contributions from Ernest Davis, Nicholas J. Hay, and Mehran Sahami

  2. Page 2
  3. Page 3
    Read page 3 as text

    Solutions for Chapter 1 Introduction 1.1 a . Dictionary definitions of intelligence talk about “the capacity to acquire and apply knowledge” or “the faculty of thought and reason” or “the ability to comprehend and profit from experience.” These are all reasonable answers, but if we want something quantifiable we would use something like “the ability to apply knowledge in order to perform better in an environment.” b . We define artificial intelligence as the study and construction of agent programs that perform well in a given environment, for a given agent architecture. c . We define an agent as an entity that takes action in response to percepts from an envi- ronment. d . We define rationality as the property of a system which does the “right thing” given what it knows. See Section 2.2 for a more complete discussion. Both describe perfect rationality, however; see Section 27.3. e . We define logical reasoning as the a process of deriving new sentences from old, such that the new sentences are necessarily true if the old ones are true. (Notice that does not refer to any specific syntax oor formal language, but it does require a well-defined notion of truth.) 1.2 See the solution for exercise 26.1 for some discussion of potential objections. The probability of fooling an interrogator depends on just how unskilled the interroga- tor is. One entrant in the 2002 Loebner prize competition (which is not quite a real Turing Test) did fool one judge, although if you look at the transcript, it is hard to imagine what that judge was thinking. There certainly have been examples of a chatbot or other online agent fooling humans. For example, see See Lenny Foner’s account of the Julia chatbot at foner.www.media.mit.edu/people/foner/Julia/. We’d say the chance today is something like 10%, with the variation depending more on the skill of the interrogator rather than the program. In 50 years, we expect that the entertainment industry (movies, video games, com- mercials) will have made sufficient investments in artificial actors to create very credible impersonators. 1.3 Yes, they are rational, because slower, deliberative actions would tend to result in more damage to the hand. If “intelligent” means “applying knowledge” or “using thought and reasoning” then it does not require intelligence to make a reflex action. 1

  4. Page 4
    Read page 4 as text

    2 Chapter 1. Introduction 1.4 No. IQ test scores correlate well with certain other measures, such as success in college, ability to make good decisions in complex, real-world situations, ability to learn new skills and subjects quickly, and so on, but only if they’re measuring fairly normal humans. The IQ test doesn’t measure everything. A program that is specialized only for IQ tests (and special- ized further only for the analogy part) would very likely perform poorly on other measures of intelligence. Consider the following analogy: if a human runs the 100m in 10 seconds, we might describe him or her as very athletic and expect competent performance in other areas such as walking, jumping, hurdling, and perhaps throwing balls; but we would not desscribe a Boeing 747 as very athletic because it can cover 100m in 0.4 seconds, nor would we expect it to be good at hurdling and throwing balls. Even for humans, IQ tests are controversial because of their theoretical presuppositions about innate ability (distinct from training effects) adn the generalizability of results. See The Mismeasure of Man by Stephen Jay Gould, Norton, 1981 or Multiple intelligences: the theory in practice by Howard Gardner, Basic Books, 1993 for more on IQ tests, what they measure, and what other aspects there are to “intelligence.” 1.5 In order of magnitude figures, the computational power of the computer is 100 times larger. 1.6 Just as you are unaware of all the steps that go into making your heart beat, you are also unaware of most of what happens in your thoughts. You do have a conscious awareness of some of your thought processes, but the majority remains opaque to your consciousness. The field of psychoanalysis is based on the idea that one needs trained professional help to analyze one’s own thoughts. 1.7 • Although bar code scanning is in a sense computer vision, these are not AI systems. The problem of reading a bar code is an extremely limited and artificial form of visual interpretation, and it has been carefully designed to be as simple as possible, given the hardware. • In many respects. The problem of determining the relevance of a web page to a query is a problem in natural language understanding, and the techniques are related to those we will discuss in Chapters 22 and 23. Search engines like Ask.com, which group the retrieved pages into categories, use clustering techniques analogous to those we discuss in Chapter 20. Likewise, other functionalities provided by a search engines use intelligent techniques; for instance, the spelling corrector uses a form of data mining based on observing users’ corrections of their own spelling errors. On the other hand, the problem of indexing billions of web pages in a way that allows retrieval in seconds is a problem in database design, not in artificial intelligence. • To a limited extent. Such menus tends to use vocabularies which are very limited – e.g. the digits, “Yes”, and “No” — and within the designers’ control, which greatly simplifies the problem. On the other hand, the programs must deal with an uncontrolled space of all kinds of voices and accents.

  5. Page 5
    Read page 5 as text

    3 The voice activated directory assistance programs used by telephone companies, which must deal with a large and changing vocabulary are certainly AI programs. • This is borderline. There is something to be said for viewing these as intelligent agents working in cyberspace. The task is sophisticated, the information available is partial, the techniques are heuristic (not guaranteed optimal), and the state of the world is dynamic. All of these are characteristic of intelligent activities. On the other hand, the task is very far from those normally carried out in human cognition. 1.8 Presumably the brain has evolved so as to carry out this operations on visual images, but the mechanism is only accessible for one particular purpose in this particular cognitive task of image processing. Until about two centuries ago there was no advantage in people (or animals) being able to compute the convolution of a Gaussian for any other purpose. The really interesting question here is what we mean by saying that the “actual person” can do something. The person can see, but he cannot compute the convolution of a Gaussian; but computing that convolution is part of seeing. This is beyond the scope of this solution manual. 1.9 Evolution tends to perpetuate organisms (and combinations and mutations of organ- isms) that are successful enough to reproduce. That is, evolution favors organisms that can optimize their performance measure to at least survive to the age of sexual maturity, and then be able to win a mate. Rationality just means optimizing performance measure, so this is in line with evolution. 1.10 This question is intended to be about the essential nature of the AI problem and what is required to solve it, but could also be interpreted as a sociological question about the current practice of AI research. A science is a field of study that leads to the acquisition of empirical knowledge by the scientific method, which involves falsifiable hypotheses about what is. A pure engineering field can be thought of as taking a fixed base of empirical knowledge and using it to solve problems of interest to society. Of course, engineers do bits of science—e.g., they measure the properties of building materials—and scientists do bits of engineering to create new devices and so on. As described in Section 1.1, the “human” side of AI is clearly an empirical science— called cognitive science these days—because it involves psychological experiments designed out to find out how human cognition actually works. What about the the “rational” side? If we view it as studying the abstract relationship among an arbitrary task environment, a computing device, and the program for that computing device that yields the best performance in the task environment, then the rational side of AI is really mathematics and engineering; it does not require any empirical knowledge about the actual world—and the actual task environment—that we inhabit; that a given program will do well in a given environment is a theorem . (The same is true of pure decision theory.) In practice, however, we are interested in task environments that do approximate the actual world, so even the rational side of AI involves finding out what the actual world is like. For example, in studying rational agents that communicate, we are interested in task environments that contain humans, so we have

  6. Page 6
    Read page 6 as text

    4 Chapter 1. Introduction to find out what human language is like. In studying perception, we tend to focus on sensors such as cameras that extract useful information from the actual world. (In a world without light, cameras wouldn’t be much use.) Moreover, to design vision algorithms that are good at extracting information from camera images, we need to understand the actual world that generates those images. Obtaining the required understanding of scene characteristics, object types, surface markings, and so on is a quite different kind of science from ordinary physics, chemistry, biology, and so on, but it is still science. In summary, AI is definitely engineering but it would not be especially useful to us if it were not also an empirical science concerned with those aspects of the real world that affect the design of intelligent systems for that world. 1.11 This depends on your definition of “intelligent” and “tell.” In one sense computers only do what the programmers command them to do, but in another sense what the programmers consciously tells the computer to do often has very little to do with what the computer actually does. Anyone who has written a program with an ornery bug knows this, as does anyone who has written a successful machine learning program. So in one sense Samuel “told” the computer “learn to play checkers better than I do, and then play that way,” but in another sense he told the computer “follow this learning algorithm” and it learned to play. So we’re left in the situation where you may or may not consider learning to play checkers to be s sign of intelligence (or you may think that learning to play in the right way requires intelligence, but not in this way), and you may think the intelligence resides in the programmer or in the computer. 1.12 The point of this exercise is to notice the parallel with the previous one. Whatever you decided about whether computers could be intelligent in 1.11, you are committed to making the same conclusion about animals (including humans), unless your reasons for de- ciding whether something is intelligent take into account the mechanism (programming via genes versus programming via a human programmer). Note that Searle makes this appeal to mechanism in his Chinese Room argument (see Chapter 26). 1.13 Again, the choice you make in 1.11 drives your answer to this question. 1.14 a . (ping-pong) A reasonable level of proficiency was achieved by Andersson’s robot (An- dersson, 1988). b . (driving in Cairo) No. Although there has been a lot of progress in automated driving, all such systems currently rely on certain relatively constant clues: that the road has shoulders and a center line, that the car ahead will travel a predictable course, that cars will keep to their side of the road, and so on. Some lane changes and turns can be made on clearly marked roads in light to moderate traffic. Driving in downtown Cairo is too unpredictable for any of these to work. c . (driving in Victorville, California) Yes, to some extent, as demonstrated in DARPA’s Urban Challenge. Some of the vehicles managed to negotiate streets, intersections, well-behaved traffic, and well-behaved pedestrians in good visual conditions.

  7. Page 7
    Read page 7 as text

    5 d . (shopping at the market) No. No robot can currently put together the tasks of moving in a crowded environment, using vision to identify a wide variety of objects, and grasping the objects (including squishable vegetables) without damaging them. The component pieces are nearly able to handle the individual tasks, but it would take a major integra- tion effort to put it all together. e . (shopping on the web) Yes. Software robots are capable of handling such tasks, par- ticularly if the design of the web grocery shopping site does not change radically over time. f . (bridge) Yes. Programs such as GIB now play at a solid level. g . (theorem proving) Yes. For example, the proof of Robbins algebra described on page 360. h . (funny story) No. While some computer-generated prose and poetry is hysterically funny, this is invariably unintentional, except in the case of programs that echo back prose that they have memorized. i . (legal advice) Yes, in some cases. AI has a long history of research into applications of automated legal reasoning. Two outstanding examples are the Prolog-based expert systems used in the UK to guide members of the public in dealing with the intricacies of the social security and nationality laws. The social security system is said to have saved the UK government approximately $150 million in its first year of operation. However, extension into more complex areas such as contract law awaits a satisfactory encoding of the vast web of common-sense knowledge pertaining to commercial transactions and agreement and business practices. j . (translation) Yes. In a limited way, this is already being done. See Kay, Gawron and Norvig (1994) and Wahlster (2000) for an overview of the field of speech translation, and some limitations on the current state of the art. k . (surgery) Yes. Robots are increasingly being used for surgery, although always under the command of a doctor. Robotic skills demonstrated at superhuman levels include drilling holes in bone to insert artificial joints, suturing, and knot-tying. They are not yet capable of planning and carrying out a complex operation autonomously from start to finish. 1.15 The progress made in this contests is a matter of fact, but the impact of that progress is a matter of opinion. • DARPA Grand Challenge for Robotic Cars In 2004 the Grand Challenge was a 240 km race through the Mojave Desert. It clearly stressed the state of the art of autonomous driving, and in fact no competitor finished the race. The best team, CMU, completed only 12 of the 240 km. In 2005 the race featured a 212km course with fewer curves and wider roads than the 2004 race. Five teams finished, with Stanford finishing first, edging out two CMU entries. This was hailed as a great achievement for robotics and for the Challenge format. In 2007 the Urban Challenge put cars in a city setting, where they had to obey traffic laws and avoid other cars. This time CMU edged out Stanford.

  8. Page 8
    Read page 8 as text

    6 Chapter 1. Introduction The competition appears to have been a good testing ground to put theory into practice, something that the failures of 2004 showed was needed. But it is important that the competition was done at just the right time, when there was theoretical work to con- solidate, as demonstrated by the earlier work by Dickmanns (whose VaMP car drove autonomously for 158km in 1995) and by Pomerleau (whose Navlab car drove 5000km across the USA, also in 1995, with the steering controlled autonomously for 98% of the trip, although the brakes and accelerator were controlled by a human driver). • International Planning Competition In 1998, five planners competed: Blackbox, HSP, IPP, SGP, and STAN. The result page ( ftp://ftp.cs.yale.edu/pub/ mcdermott/aipscomp-results.html ) stated “all of these planners performed very well, compared to the state of the art a few years ago.” Most plans found were 30 or 40 steps, with some over 100 steps. In 2008, the competition had expanded quite a bit: there were more tracks (satisficing vs. optimizing; sequential vs. temporal; static vs. learning). There were about 25 planners, including submissions from the 1998 groups (or their descendants) and new groups. Solutions found were much longer than in 1998. In sum, the field has progressed quite a bit in participation, in breadth, and in power of the planners. In the 1990s it was possible to publish a Planning paper that discussed only a theoretical approach; now it is necessary to show quantitative evidence of the efficacy of an approach. The field is stronger and more mature now, and it seems that the planning competition deserves some of the credit. However, some researchers feel that too much emphasis is placed on the particular classes of problems that appear in the competitions, and not enough on real-world applications. • Robocup Robotics Soccer This competition has proved extremely popular, attracting 407 teams from 43 countries in 2009 (up from 38 teams from 11 countries in 1997). The robotic platform has advanced to a more capable humanoid form, and the strategy and tactics have advanced as well. Although the competition has spurred innovations in distributed control, the winning teams in recent years have relied more on individual ball-handling skills than on advanced teamwork. The competition has served to increase interest and participation in robotics, although it is not clear how well they are advancing towards the goal of defeating a human team by 2050. • TREC Information Retrieval Conference This is one of the oldest competitions, started in 1992. The competitions have served to bring together a community of re- searchers, have led to a large literature of publications, and have seen progress in par- ticipation and in quality of results over the years. In the early years, TREC served its purpose as a place to do evaluations of retrieval algorithms on text collections that were large for the time. However, starting around 2000 TREC became less relevant as the advent of the World Wide Web created a corpus that was available to anyone and was much larger than anything TREC had created, and the development of commercial search engines surpassed academic research. • NIST Open Machine Translation Evaluation This series of evaluations (explicitly not labelled a “competition”) has existed since 2001. Since then we have seen great advances in Machine Translation quality as well as in the number of languages covered.

  9. Page 9
    Read page 9 as text

    7 The dominant approach has switched from one based on grammatical rules to one that relies primarily on statistics. The NIST evaluations seem to track these changes well, but don’t appear to be driving the changes. Overall, we see that whatever you measure is bound to increase over time. For most of these competitions, the measurement was a useful one, and the state of the art has progressed. In the case of ICAPS, some planning researchers worry that too much attention has been lavished on the competition itself. In some cases, progress has left the competition behind, as in TREC, where the resources available to commercial search engines outpaced those available to academic researchers. In this case the TREC competition was useful—it helped train many of the people who ended up in commercial search engines—and in no way drew energy away from new ideas.

  10. Page 10
    Read page 10 as text

    Solutions for Chapter 2 Intelligent Agents 2.1 This question tests the student’s understanding of environments, rational actions, and performance measures. Any sequential environment in which rewards may take time to arrive will work, because then we can arrange for the reward to be “over the horizon.” Suppose that in any state there are two action choices, a and b , and consider two cases: the agent is in state s at time T or at time T − 1 . In state s , action a reaches state s ′ with reward 0, while action b reaches state s again with reward 1; in s ′ either action gains reward 10. At time T − 1 , it’s rational to do a in s , with expected total reward 10 before time is up; but at time T , it’s rational to do b with total expected reward 1 because the reward of 10 cannot be obtained before time is up. Students may also provide common-sense examples from real life: investments whose payoff occurs after the end of life, exams where it doesn’t make sense to start the high-value question with too little time left to get the answer, and so on. The environment state can include a clock, of course; this doesn’t change the gist of the answer—now the action will depend on the clock as well as on the non-clock part of the state—but it does mean that the agent can never be in the same state twice. 2.2 Notice that for our simple environmental assumptions we need not worry about quanti- tative uncertainty. a . It suffices to show that for all possible actual environments (i.e., all dirt distributions and initial locations), this agent cleans the squares at least as fast as any other agent. This is trivially true when there is no dirt. When there is dirt in the initial location and none in the other location, the world is clean after one step; no agent can do better. When there is no dirt in the initial location but dirt in the other, the world is clean after two steps; no agent can do better. When there is dirt in both locations, the world is clean after three steps; no agent can do better. (Note: in general, the condition stated in the first sentence of this answer is much stricter than necessary for an agent to be rational.) b . The agent in (a) keeps moving backwards and forwards even after the world is clean. It is better to do NoOp once the world is clean (the chapter says this). Now, since the agent’s percept doesn’t say whether the other square is clean, it would seem that the agent must have some memory to say whether the other square has already been cleaned. To make this argument rigorous is more difficult—for example, could the agent arrange things so that it would only be in a clean left square when the right square 8

  11. Page 11
    Read page 11 as text

    9 was already clean? As a general strategy, an agent can use the environment itself as a form of external memory —a common technique for humans who use things like EXTERNAL MEMORY appointment calendars and knots in handkerchiefs. In this particular case, however, that is not possible. Consider the reflex actions for [ A, Clean ] and [ B, Clean ] . If either of these is NoOp , then the agent will fail in the case where that is the initial percept but the other square is dirty; hence, neither can be NoOp and therefore the simple reflex agent is doomed to keep moving. In general, the problem with reflex agents is that they have to do the same thing in situations that look the same, even when the situations are actually quite different. In the vacuum world this is a big liability, because every interior square (except home) looks either like a square with dirt or a square without dirt. c . If we consider asymptotically long lifetimes, then it is clear that learning a map (in some form) confers an advantage because it means that the agent can avoid bumping into walls. It can also learn where dirt is most likely to accumulate and can devise an optimal inspection strategy. The precise details of the exploration method needed to construct a complete map appear in Chapter 4; methods for deriving an optimal inspection/cleanup strategy are in Chapter 21. 2.3 a . An agent that senses only partial information about the state cannot be perfectly ra- tional. False. Perfect rationality refers to the ability to make good decisions given the sensor information received. b . There exist task environments in which no pure reflex agent can behave rationally. True. A pure reflex agent ignores previous percepts, so cannot obtain an optimal state estimate in a partially observable environment. For example, correspondence chess is played by sending moves; if the other player’s move is the current percept, a reflex agent could not keep track of the board state and would have to respond to, say, “a4” in the same way regardless of the position in which it was played. c . There exists a task environment in which every agent is rational. True. For example, in an environment with a single state, such that all actions have the same reward, it doesn’t matter which action is taken. More generally, any environment that is reward-invariant under permutation of the actions will satisfy this property. d . The input to an agent program is the same as the input to the agent function. False. The agent function, notionally speaking, takes as input the entire percept se- quence up to that point, whereas the agent program takes the current percept only. e . Every agent function is implementable by some program/machine combination. False. For example, the environment may contain Turing machines and input tapes and the agent’s job is to solve the halting problem; there is an agent function that specifies the right answers, but no agent program can implement it. Another example would be an agent function that requires solving intractable problem instances of arbitrary size in constant time.

  12. Page 12
    Read page 12 as text

    10 Chapter 2. Intelligent Agents f . Suppose an agent selects its action uniformly at random from the set of possible actions. There exists a deterministic task environment in which this agent is rational. True. This is a special case of (c); if it doesn’t matter which action you take, selecting randomly is rational. g . It is possible for a given agent to be perfectly rational in two distinct task environments. True. For example, we can arbitrarily modify the parts of the environment that are unreachable by any optimal policy as long as they stay unreachable. h . Every agent is rational in an unobservable environment. False. Some actions are stupid—and the agent may know this if it has a model of the environment—even if one cannot perceive the environment state. i . A perfectly rational poker-playing agent never loses. False. Unless it draws the perfect hand, the agent can always lose if an opponent has better cards. This can happen for game after game. The correct statement is that the agent’s expected winnings are nonnegative. 2.4 Many of these can actually be argued either way, depending on the level of detail and abstraction. A. Partially observable, stochastic, sequential, dynamic, continuous, multi-agent. B. Partially observable, stochastic, sequential, dynamic, continuous, single agent (unless there are alien life forms that are usefully modeled as agents). C. Partially observable, deterministic, sequential, static, discrete, single agent. This can be multi-agent and dynamic if we buy books via auction, or dynamic if we purchase on a long enough scale that book offers change. D. Fully observable, stochastic, episodic (every point is separate), dynamic, continuous, multi-agent. E. Fully observable, stochastic, episodic, dynamic, continuous, single agent. F. Fully observable, stochastic, sequential, static, continuous, single agent. G. Fully observable, deterministic, sequential, static, continuous, single agent. H. Fully observable, strategic, sequential, static, discrete, multi-agent. 2.5 The following are just some of the many possible definitions that can be written: • Agent : an entity that perceives and acts; or, one that can be viewed as perceiving and acting. Essentially any object qualifies; the key point is the way the object implements an agent function. (Note: some authors restrict the term to programs that operate on behalf of a human, or to programs that can cause some or all of their code to run on other machines on a network, as in mobile agents .) MOBILE AGENT • Agent function : a function that specifies the agent’s action in response to every possible percept sequence. • Agent program : that program which, combined with a machine architecture, imple- ments an agent function. In our simple designs, the program takes a new percept on each invocation and returns an action.

  13. Page 13
    Read page 13 as text

    11 • Rationality : a property of agents that choose actions that maximize their expected util- ity, given the percepts to date. • Autonomy : a property of agents whose behavior is determined by their own experience rather than solely by their initial programming. • Reflex agent : an agent whose action depends only on the current percept. • Model-based agent : an agent whose action is derived directly from an internal model of the current world state that is updated over time. • Goal-based agent : an agent that selects actions that it believes will achieve explicitly represented goals. • Utility-based agent : an agent that selects actions that it believes will maximize the expected utility of the outcome state. • Learning agent : an agent whose behavior improves over time based on its experience. 2.6 Although these questions are very simple, they hint at some very fundamental issues. Our answers are for the simple agent designs for static environments where nothing happens while the agent is deliberating; the issues get even more interesting for dynamic environ- ments. a . Yes; take any agent program and insert null statements that do not affect the output. b . Yes; the agent function might specify that the agent print true when the percept is a Turing machine program that halts, and false otherwise. (Note: in dynamic environ- ments, for machines of less than infinite speed, the rational agent function may not be implementable; e.g., the agent function that always plays a winning move, if any, in a game of chess.) c . Yes; the agent’s behavior is fixed by the architecture and program. d . There are 2 n agent programs, although many of these will not run at all. (Note: Any given program can devote at most n bits to storage, so its internal state can distinguish among only 2 n past histories. Because the agent function specifies actions based on per- cept histories, there will be many agent functions that cannot be implemented because of lack of memory in the machine.) e . It depends on the program and the environment. If the environment is dynamic, speed- ing up the machine may mean choosing different (perhaps better) actions and/or acting sooner. If the environment is static and the program pays no attention to the passage of elapsed time, the agent function is unchanged. 2.7 The design of goal- and utility-based agents depends on the structure of the task en- vironment. The simplest such agents, for example those in chapters 3 and 10, compute the agent’s entire future sequence of actions in advance before acting at all. This strategy works for static and deterministic environments which are either fully-known or unobservable For fully-observable and fully-known static environments a policy can be computed in advance which gives the action to by taken in any given state.

  14. Page 14
    Read page 14 as text

    12 Chapter 2. Intelligent Agents function G OAL -B ASED -A GENT ( percept ) returns an action persistent : state , the agent’s current conception of the world state model , a description of how the next state depends on current state and action goal , a description of the desired goal state plan , a sequence of actions to take, initially empty action , the most recent action, initially none state ← U PDATE -S TATE ( state , action , percept , model ) if G OAL -A CHIEVED ( state , goal ) then return a null action if plan is empty then plan ← P LAN ( state , goal , model ) action ← F IRST ( plan ) plan ← R EST ( plan ) return action Figure S2.1 A goal-based agent. For partially-observable environments the agent can compute a conditional plan, which specifies the sequence of actions to take as a function of the agent’s perception. In the ex- treme, a conditional plan gives the agent’s response to every contingency, and so it is a repre- sentation of the entire agent function. In all cases it may be either intractable or too expensive to compute everything out in advance. Instead of a conditional plan, it may be better to compute a single sequence of actions which is likely to reach the goal, then monitor the environment to check whether the plan is succeeding, repairing or replanning if it is not. It may be even better to compute only the start of this plan before taking the first action, continuing to plan at later time steps. Pseudocode for simple goal-based agent is given in Figure S2.1. G OAL -A CHIEVED tests to see whether the current state satisfies the goal or not, doing nothing if it does. P LAN computes a sequence of actions to take to achieve the goal. This might return only a prefix of the full plan, the rest will be computed after the prefix is executed. This agent will act to maintain the goal: if at any point the goal is not satisfied it will (eventually) replan to achieve the goal again. At this level of abstraction the utility-based agent is not much different than the goal- based agent, except that action may be continuously required (there is not necessarily a point where the utility function is “satisfied”). Pseudocode is given in Figure S2.2. 2.8 The file "agents/environments/vacuum.lisp" in the code repository imple- ments the vacuum-cleaner environment. Students can easily extend it to generate different shaped rooms, obstacles, and so on. 2.9 A reflex agent program implementing the rational agent function described in the chap- ter is as follows: (defun reflex-rational-vacuum-agent (percept) (destructuring-bind (location status) percept

  15. Page 15
    Read page 15 as text

    13 function U TILITY -B ASED -A GENT ( percept ) returns an action persistent : state , the agent’s current conception of the world state model , a description of how the next state depends on current state and action utility − function , a description of the agent’s utility function plan , a sequence of actions to take, initially empty action , the most recent action, initially none state ← U PDATE -S TATE ( state , action , percept , model ) if plan is empty then plan ← P LAN ( state , utility − function , model ) action ← F IRST ( plan ) plan ← R EST ( plan ) return action Figure S2.2 A utility-based agent. (cond ((eq status ’Dirty) ’Suck) ((eq location ’A) ’Right) (t ’Left)))) For states 1, 3, 5, 7 in Figure 4.9, the performance measures are 1996, 1999, 1998, 2000 respectively. 2.10 a . No; see answer to 2.4(b). b . See answer to 2.4(b). c . In this case, a simple reflex agent can be perfectly rational. The agent can consist of a table with eight entries, indexed by percept, that specifies an action to take for each possible state. After the agent acts, the world is updated and the next percept will tell the agent what to do next. For larger environments, constructing a table is infeasible. Instead, the agent could run one of the optimal search algorithms in Chapters 3 and 4 and execute the first step of the solution sequence. Again, no internal state is required , but it would help to be able to store the solution sequence instead of recomputing it for each new percept. 2.11 a . Because the agent does not know the geography and perceives only location and local dirt, and cannot remember what just happened, it will get stuck forever against a wall when it tries to move in a direction that is blocked—that is, unless it randomizes. b . One possible design cleans up dirt and otherwise moves randomly: (defun randomized-reflex-vacuum-agent (percept) (destructuring-bind (location status) percept (cond ((eq status ’Dirty) ’Suck) (t (random-element ’(Left Right Up Down))))))

  16. Page 16
    Read page 16 as text

    14 Chapter 2. Intelligent Agents Figure S2.3 An environment in which random motion will take a long time to cover all the squares. This is fairly close to what the Roomba TM vacuum cleaner does (although the Roomba has a bump sensor and randomizes only when it hits an obstacle). It works reasonably well in nice, compact environments. In maze-like environments or environments with small connecting passages, it can take a very long time to cover all the squares. c . An example is shown in Figure S2.3. Students may also wish to measure clean-up time for linear or square environments of different sizes, and compare those to the efficient online search algorithms described in Chapter 4. d . A reflex agent with state can build a map (see Chapter 4 for details). An online depth- first exploration will reach every state in time linear in the size of the environment; therefore, the agent can do much better than the simple reflex agent. The question of rational behavior in unknown environments is a complex one but it is worth encouraging students to think about it. We need to have some notion of the prior probability distribution over the class of environments; call this the initial belief state . Any action yields a new percept that can be used to update this distribution, moving the agent to a new belief state. Once the environment is completely explored, the belief state collapses to a single possible environment. Therefore, the problem of optimal exploration can be viewed as a search for an optimal strategy in the space of possible belief states. This is a well-defined, if horrendously intractable, problem. Chapter 21 discusses some cases where optimal exploration is possible. Another concrete example of exploration is the Minesweeper computer game (see Exercise 7.22). For very small Minesweeper environments, optimal exploration is feasible although the belief state

218 more pages in the full document

Unlock it once and it stays in your library, ready to chat with or turn into flashcards.

Unlock the full document
See all

Study this document with CramX

Once it is in your library, every tool can work from it.