Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Vacuum World \n",
"\n",
"In this notebook, we will be discussing about **the structure of agents** through an example of the **vacuum agent**. The job of AI is to design an **agent program** that implements the agent function: the mapping from percepts to actions. We assume this program will run on some sort of computing device with physical sensors and actuators: we call this the **architecture**: \n",
"\n",
" agent = architecture + program "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before moving on, please review [<b>agents.ipynb</b>](https://github.com/aimacode/aima-python/blob/master/agents.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Agent Programs\n",
"\n",
"An agent program takes the current percept as input from the sensors and return an action to the actuators. There is a difference between an agent program and an agent function: an agent program takes the current percept as input whereas an agent function takes the entire percept history. \n",
"The agent program takes just the current percept as input because nothing more is available from the environment; if the agent's actions need to depend on the entire percept sequence, the agent will have to remember the percept. \n",
"\n",
"We'll discuss the following agent programs here with the help of the vacuum world example:\n",
"\n",
"* Random Agent Program\n",
"* Table Driven Agent Program\n",
"* Simple Reflex Agent Program\n",
"* Model-Based Reflex Agent Program\n",
"* Goal-Based Agent Program\n",
"* Utility-Based Agent Program"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Random Agent Program\n",
"\n",
"A random agent program, as the name suggests, choses an action at random, without taking into account the percepts. \n",
"Here, we will demonstrate a random vacuum agent for a trivial vacuum environment, that is, the two-state environment."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's begin by importing all the functions from the agents module:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: '/home/apurv/aima-python/aima-data/orings.csv'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-3c92a8b6a5a1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0magents\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mnotebook\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpsource\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m~/aima-python/notebook.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mgames\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mTicTacToe\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0malphabeta_player\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrandom_player\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mFig52Extended\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minfinity\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mlogic\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mparse_definite_clause\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstandardize_variables\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0munify\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msubst\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mlearning\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mDataSet\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mIPython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisplay\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mHTML\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdisplay\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcollections\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mCounter\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdefaultdict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/aima-python/learning.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1105\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1106\u001b[0m orings = DataSet(name='orings', target='Distressed',\n\u001b[0;32m-> 1107\u001b[0;31m attrnames=\"Rings Distressed Temp Pressure Flightnum\")\n\u001b[0m\u001b[1;32m 1108\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1109\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/aima-python/learning.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, examples, attrs, attrnames, target, inputs, values, distance, name, source, exclude)\u001b[0m\n\u001b[1;32m 96\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexamples\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparse_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexamples\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 97\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mexamples\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 98\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexamples\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparse_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mopen_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m'.csv'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 99\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 100\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexamples\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexamples\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/aima-python/utils.py\u001b[0m in \u001b[0;36mopen_data\u001b[0;34m(name, mode)\u001b[0m\n\u001b[1;32m 414\u001b[0m \u001b[0maima_file\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maima_root\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'aima-data'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 415\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 416\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maima_file\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 417\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 418\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/home/apurv/aima-python/aima-data/orings.csv'"
]
}
],
"source": [
"from agents import *\n",
"from notebook import psource"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us first see how we define the TrivialVacuumEnvironment. Run the next cell to see how abstract class TrivialVacuumEnvironment is defined in agents module:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"%psource TrivialVacuumEnvironment"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"State of the Environment: {(1, 0): 'Clean', (0, 0): 'Dirty'}.\n"
]
}
],
"source": [
"# These are the two locations for the two-state environment.\n",
"loc_A, loc_B = (0, 0), (1, 0)\n",
"\n",
"# Initialise the two-state environment.\n",
"trivial_vacuum_env = TrivialVacuumEnvironment()\n",
"\n",
"# Check the intial state of the environment.\n",
"print(\"State of the Environment: {}.\".format(trivial_vacuum_env.status))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's create our agent now. This agent will chose any of the actions from 'Right', 'Left', 'Suck' and 'NoOp' (No Operation) randomly. "
]
},
{
"cell_type": "code",
"execution_count": 120,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Create the random agent.\n",
"random_agent = Agent(program=RandomAgentProgram(['Right', 'Left', 'Suck', 'NoOp']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will now add our agent to the environment."
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RandomVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"# Add agent to the environment.\n",
"trivial_vacuum_env.add_thing(random_agent)\n",
"\n",
"print(\"RandomVacuumAgent is located at {}.\".format(random_agent.location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's run our environment now."
]
},
{
"cell_type": "code",
"execution_count": 122,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"State of the Environment: {(1, 0): 'Clean', (0, 0): 'Dirty'}.\n",
"RandomVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"# Running the environment.\n",
"trivial_vacuum_env.step()\n",
"\n",
"# Check the current state of the environment.\n",
"print(\"State of the Environment: {}.\".format(trivial_vacuum_env.status))\n",
"\n",
"print(\"RandomVacuumAgent is located at {}.\".format(random_agent.location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Table Driven Agent Program\n",
"\n",
"A table driven agent program keeps track of the percept sequence and then uses it to index into a table of actions to decide what to do. The table represents eplicitly the agent function that the agent program embodies. \n",
"In the two-state vacuum world, the table would consist of all the possible states of the agent."
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"table = {((loc_A, 'Clean'),): 'Right',\n",
" ((loc_A, 'Dirty'),): 'Suck',\n",
" ((loc_B, 'Clean'),): 'Left',\n",
" ((loc_B, 'Dirty'),): 'Suck',\n",
" ((loc_A, 'Clean'), (loc_A, 'Clean')): 'Right',\n",
" ((loc_A, 'Clean'), (loc_A, 'Dirty')): 'Suck',\n",
" ((loc_A, 'Clean'), (loc_A, 'Clean'), (loc_A, 'Clean')): 'Right',\n",
" ((loc_A, 'Clean'), (loc_A, 'Clean'), (loc_A, 'Dirty')): 'Suck',\n",
" }"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will now create a table driven agent program for our two-state environment."
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Create a table driven agent.\n",
"table_driven_agent = Agent(program=TableDrivenAgentProgram(table=table))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since we are using the same environment, let us remove the previously added random agent from the environment to avoid confusion."
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"trivial_vacuum_env.delete_thing(random_agent)"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TableDrivenVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"# Add the table driven agent to the environment\n",
"trivial_vacuum_env.add_thing(table_driven_agent)\n",
"\n",
"print(\"TableDrivenVacuumAgent is located at {}.\".format(table_driven_agent.location))"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"State of the Environment: {(1, 0): 'Clean', (0, 0): 'Clean'}.\n",
"TableDrivenVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"# Run the environment.\n",
"trivial_vacuum_env.step()\n",
"\n",
"# Check the current state of the environment.\n",
"print(\"State of the Environment: {}.\".format(trivial_vacuum_env.status))\n",
"\n",
"print(\"TableDrivenVacuumAgent is located at {}.\".format(table_driven_agent.location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Simple Reflex Agent Program\n",
"\n",
"A simple reflex agent program selects actions on the basis of the <i>current</i> percept, ignoring the rest of the percept history. These agents work on a **condition-action rule** (also called **situation-action rule**, **production** or **if-then rule**), which tell the agent the action to trigger when a particular situtation is encountered. \n",
"\n",
"The schematic diagram shown in **Figure 2.9** of the book will make this more clear:\n",
"\n",
"<img src=\"/files/images/simple_reflex_agent.jpg\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us now create a simple reflex agent for the environment."
]
},
{
"cell_type": "code",
"execution_count": 131,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Delete the previously added table driven agent.\n",
"trivial_vacuum_env.delete_thing(table_driven_agent)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To create our agent, we need two functions: INTERPRET-INPUT function, which generates an abstracted description of the current state from the percerpt and the RULE-MATCH function, which returns the first rule in the set of rules that matches the given state description."
]
},
{
"cell_type": "code",
"execution_count": 134,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# TODO: Implement these functions for two-dimensional environment.\n",
"# Interpret-input function for the two-state environment.\n",
"def interpret_input(percept):\n",
" pass\n",
"\n",
"rules = None\n",
"\n",
"# Rule-match function for the two-state environment.\n",
"def rule_match(state, rule):\n",
" for rule in rules:\n",
" if rule.matches(state):\n",
" return rule \n",
" \n",
"# Create a simple reflex agent the two-state environment.\n",
"simple_reflex_agent = ReflexVacuumAgent()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now add the agent to the environment:"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SimpleReflexVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"trivial_vacuum_env.add_thing(simple_reflex_agent)\n",
"\n",
"print(\"SimpleReflexVacuumAgent is located at {}.\".format(simple_reflex_agent.location))"
]
},
{
"cell_type": "code",
"execution_count": 137,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"State of the Environment: {(1, 0): 'Clean', (0, 0): 'Clean'}.\n",
"SimpleReflexVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"# Run the environment.\n",
"trivial_vacuum_env.step()\n",
"\n",
"# Check the current state of the environment.\n",
"print(\"State of the Environment: {}.\".format(trivial_vacuum_env.status))\n",
"\n",
"print(\"SimpleReflexVacuumAgent is located at {}.\".format(simple_reflex_agent.location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Model-Based Reflex Agent Program\n",
"\n",
"A model-based reflex agent maintains some sort of <b>internal state</b> that depends on the percept history and thereby reflects at least some of the unobserved aspects of the current state. In additon to this, it also requires a <b>model</b> of the world, that is, knowledge about \"how the world works\". \n",
"\n",
"The schematic diagram shown in figure 2.11 of the book will make this more clear:\n",
"<img src=\"files/images/model_based_reflex_agent.jpg\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will now create a model-based reflex agent for the environment:"
]
},
{
"cell_type": "code",
"execution_count": 139,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"list.remove(x): x not in list\n",
" in Environment delete_thing\n",
" Thing to be removed: <Agent> at (0, 0)\n",
" from list: []\n"
]
}
],
"source": [
"# Delete the previously added simple reflex agent.\n",
"trivial_vacuum_env.delete_thing(simple_reflex_agent)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We need a another function UPDATE-STATE which will be reponsible for creating a new state description."
]
},
{
"cell_type": "code",
"execution_count": 140,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ModelBasedVacuumAgent is located at (0, 0).\n"
]
}
],
"source": [
"# TODO: Implement this function for the two-dimensional environment.\n",
"def update_state(state, action, percept, model):\n",
" pass\n",
"\n",
"# Create a model-based reflex agent.\n",
"model_based_reflex_agent = ModelBasedVacuumAgent()\n",
"\n",
"# Add the agent to the environment.\n",
"trivial_vacuum_env.add_thing(model_based_reflex_agent)\n",
"\n",
"print(\"ModelBasedVacuumAgent is located at {}.\".format(model_based_reflex_agent.location))"
]
},
{
"cell_type": "code",
"execution_count": 143,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"State of the Environment: {(1, 0): 'Clean', (0, 0): 'Clean'}.\n",
"ModelBasedVacuumAgent is located at (1, 0).\n"
]
}
],
"source": [
"# Run the environment.\n",
"trivial_vacuum_env.step()\n",
"\n",
"# Check the current state of the environment.\n",
"print(\"State of the Environment: {}.\".format(trivial_vacuum_env.status))\n",
"\n",
"print(\"ModelBasedVacuumAgent is located at {}.\".format(model_based_reflex_agent.location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Goal-Based Agent Program \n",
"\n",
"A goal-based agent needs some sort of <b>goal</b> information that describes situations that are desirable, apart from the current state description. \n",
"<b>Figure 2.13</b> of the book shows a model-based, goal-based agent: \n",
"<img src=\"files/images/model_goal_based_agent.jpg\">\n",
"\n",
"<b>Search</b> (Chapters 3 to 5) and <b>Planning</b> (Chapters 10 to 11) are the subfields of AI devoted to finding action sequences that achieve the agent's goals.\n",
"\n",
"## Utility-Based Agent Program\n",
"\n",
"A utility-based agent maximizes its <b>utility</b> using the agent's <b>utility function</b>, which is essentially an internalization of the agent's performance measure. \n",
"<b>Figure 2.14</b> of the book shows a model-based, utility-based agent:\n",
"<img src=\"files/images/model_utility_based_agent.jpg\">\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}