Newer
Older
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n",
" \"http://www.w3.org/TR/html4/strict.dtd\">\n",
"\n",
"<html>\n",
"<head>\n",
" <title></title>\n",
" <meta http-equiv=\"content-type\" content=\"text/html; charset=None\">\n",
" <style type=\"text/css\">\n",
"td.linenos { background-color: #f0f0f0; padding-right: 10px; }\n",
"span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }\n",
"pre { line-height: 125%; }\n",
"body .hll { background-color: #ffffcc }\n",
"body { background: #f8f8f8; }\n",
"body .c { color: #408080; font-style: italic } /* Comment */\n",
"body .err { border: 1px solid #FF0000 } /* Error */\n",
"body .k { color: #008000; font-weight: bold } /* Keyword */\n",
"body .o { color: #666666 } /* Operator */\n",
"body .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
"body .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
"body .cp { color: #BC7A00 } /* Comment.Preproc */\n",
"body .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
"body .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
"body .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
"body .gd { color: #A00000 } /* Generic.Deleted */\n",
"body .ge { font-style: italic } /* Generic.Emph */\n",
"body .gr { color: #FF0000 } /* Generic.Error */\n",
"body .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
"body .gi { color: #00A000 } /* Generic.Inserted */\n",
"body .go { color: #888888 } /* Generic.Output */\n",
"body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
"body .gs { font-weight: bold } /* Generic.Strong */\n",
"body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
"body .gt { color: #0044DD } /* Generic.Traceback */\n",
"body .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
"body .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
"body .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
"body .kp { color: #008000 } /* Keyword.Pseudo */\n",
"body .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
"body .kt { color: #B00040 } /* Keyword.Type */\n",
"body .m { color: #666666 } /* Literal.Number */\n",
"body .s { color: #BA2121 } /* Literal.String */\n",
"body .na { color: #7D9029 } /* Name.Attribute */\n",
"body .nb { color: #008000 } /* Name.Builtin */\n",
"body .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
"body .no { color: #880000 } /* Name.Constant */\n",
"body .nd { color: #AA22FF } /* Name.Decorator */\n",
"body .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
"body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
"body .nf { color: #0000FF } /* Name.Function */\n",
"body .nl { color: #A0A000 } /* Name.Label */\n",
"body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
"body .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
"body .nv { color: #19177C } /* Name.Variable */\n",
"body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
"body .w { color: #bbbbbb } /* Text.Whitespace */\n",
"body .mb { color: #666666 } /* Literal.Number.Bin */\n",
"body .mf { color: #666666 } /* Literal.Number.Float */\n",
"body .mh { color: #666666 } /* Literal.Number.Hex */\n",
"body .mi { color: #666666 } /* Literal.Number.Integer */\n",
"body .mo { color: #666666 } /* Literal.Number.Oct */\n",
"body .sa { color: #BA2121 } /* Literal.String.Affix */\n",
"body .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
"body .sc { color: #BA2121 } /* Literal.String.Char */\n",
"body .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
"body .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
"body .s2 { color: #BA2121 } /* Literal.String.Double */\n",
"body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
"body .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
"body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
"body .sx { color: #008000 } /* Literal.String.Other */\n",
"body .sr { color: #BB6688 } /* Literal.String.Regex */\n",
"body .s1 { color: #BA2121 } /* Literal.String.Single */\n",
"body .ss { color: #19177C } /* Literal.String.Symbol */\n",
"body .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
"body .fm { color: #0000FF } /* Name.Function.Magic */\n",
"body .vc { color: #19177C } /* Name.Variable.Class */\n",
"body .vg { color: #19177C } /* Name.Variable.Global */\n",
"body .vi { color: #19177C } /* Name.Variable.Instance */\n",
"body .vm { color: #19177C } /* Name.Variable.Magic */\n",
"body .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
"\n",
" </style>\n",
"</head>\n",
"<body>\n",
"<h2></h2>\n",
"\n",
"<div class=\"highlight\"><pre><span></span><span class=\"k\">def</span> <span class=\"nf\">spare_tire</span><span class=\"p\">():</span>\n",
" <span class=\"sd\">"""[Figure 10.2] SPARE-TIRE-PROBLEM</span>\n",
"\n",
"<span class=\"sd\"> A problem involving changing the flat tire of a car</span>\n",
"<span class=\"sd\"> with a spare tire from the trunk.</span>\n",
"\n",
"<span class=\"sd\"> Example:</span>\n",
"<span class=\"sd\"> >>> from planning import *</span>\n",
"<span class=\"sd\"> >>> st = spare_tire()</span>\n",
"<span class=\"sd\"> >>> st.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> st.act(expr('Remove(Spare, Trunk)'))</span>\n",
"<span class=\"sd\"> >>> st.act(expr('Remove(Flat, Axle)'))</span>\n",
"<span class=\"sd\"> >>> st.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> st.act(expr('PutOn(Spare, Axle)'))</span>\n",
"<span class=\"sd\"> >>> st.goal_test()</span>\n",
"<span class=\"sd\"> True</span>\n",
"<span class=\"sd\"> >>></span>\n",
"<span class=\"sd\"> """</span>\n",
" <span class=\"k\">return</span> <span class=\"n\">PlanningProblem</span><span class=\"p\">(</span><span class=\"n\">init</span><span class=\"o\">=</span><span class=\"s1\">'Tire(Flat) & Tire(Spare) & At(Flat, Axle) & At(Spare, Trunk)'</span><span class=\"p\">,</span>\n",
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
" <span class=\"n\">goals</span><span class=\"o\">=</span><span class=\"s1\">'At(Spare, Axle) & At(Flat, Ground)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">actions</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'Remove(obj, loc)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'At(obj, loc)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'At(obj, Ground) & ~At(obj, loc)'</span><span class=\"p\">),</span>\n",
" <span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'PutOn(t, Axle)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'Tire(t) & At(t, Ground) & ~At(Flat, Axle)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'At(t, Axle) & ~At(t, Ground)'</span><span class=\"p\">),</span>\n",
" <span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'LeaveOvernight'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">''</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'~At(Spare, Ground) & ~At(Spare, Axle) & ~At(Spare, Trunk) & </span><span class=\"se\">\\</span>\n",
"<span class=\"s1\"> ~At(Flat, Ground) & ~At(Flat, Axle) & ~At(Flat, Trunk)'</span><span class=\"p\">)])</span>\n",
"</pre></div>\n",
"</body>\n",
"</html>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"psource(spare_tire)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**At(obj, loc):** object **'obj'** is at location **'loc'**.\n",
"\n",
"**~At(obj, loc):** object **'obj'** is _not_ at location **'loc'**.\n",
"\n",
"**Tire(t):** Declare a tire of type **'t'**.\n",
"\n",
"Let us now define an object of `spare_tire` problem:"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"spareTire = spare_tire()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before taking any actions, we will check if `spare_tire` has reached its goal:"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"source": [
"print(spareTire.goal_test())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we can see, it hasn't completed the goal. \n",
"We now define a possible solution that can help us reach the goal of having a spare tire mounted onto the car's axle. \n",
"The actions are then carried out on the `spareTire` PlanningProblem.\n",
"\n",
"The actions available to us are the following: Remove, PutOn\n",
"\n",
"**Remove(obj, loc):** Remove the tire **'obj'** from the location **'loc'**.\n",
"\n",
"**PutOn(t, Axle):** Attach the tire **'t'** on the Axle.\n",
"\n",
"**LeaveOvernight():** We live in a particularly bad neighborhood and all tires, flat or not, are stolen if we leave them overnight.\n",
"\n"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"solution = [expr(\"Remove(Flat, Axle)\"),\n",
" expr(\"Remove(Spare, Trunk)\"),\n",
" expr(\"PutOn(Spare, Axle)\")]\n",
"\n",
"for action in solution:\n",
" spareTire.act(action)"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"print(spareTire.goal_test())"
]
},
{
"cell_type": "markdown",
"source": [
"This is a valid solution.\n",
"<br>\n",
"Another possible solution is"
]
},
{
"cell_type": "code",
"spareTire = spare_tire()\n",
"\n",
"solution = [expr('Remove(Spare, Trunk)'),\n",
" expr('Remove(Flat, Axle)'),\n",
" expr('PutOn(Spare, Axle)')]\n",
"\n",
"for action in solution:\n",
" spareTire.act(action)"
]
},
{
"cell_type": "code",
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"print(spareTire.goal_test())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that both solutions work, which means that the problem can be solved irrespective of the order in which the `Remove` actions take place, as long as both `Remove` actions take place before the `PutOn` action."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have successfully mounted a spare tire onto the axle."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Three Block Tower Problem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This problem's domain consists of a set of cube-shaped blocks sitting on a table. \n",
"The blocks can be stacked, but only one block can fit directly on top of another.\n",
"A robot arm can pick up a block and move it to another position, either on the table or on top of another block. \n",
"The arm can pick up only one block at a time, so it cannot pick up a block that has another one on it. \n",
"The goal will always be to build one or more stacks of blocks. \n",
"In our case, we consider only three blocks.\n",
"The particular configuration we will use is called the Sussman anomaly after Prof. Gerry Sussman."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's take a look at the definition of `three_block_tower()` in the module."
]
},
{
"cell_type": "code",
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n",
" \"http://www.w3.org/TR/html4/strict.dtd\">\n",
"\n",
"<html>\n",
"<head>\n",
" <title></title>\n",
" <meta http-equiv=\"content-type\" content=\"text/html; charset=None\">\n",
" <style type=\"text/css\">\n",
"td.linenos { background-color: #f0f0f0; padding-right: 10px; }\n",
"span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }\n",
"pre { line-height: 125%; }\n",
"body .hll { background-color: #ffffcc }\n",
"body { background: #f8f8f8; }\n",
"body .c { color: #408080; font-style: italic } /* Comment */\n",
"body .err { border: 1px solid #FF0000 } /* Error */\n",
"body .k { color: #008000; font-weight: bold } /* Keyword */\n",
"body .o { color: #666666 } /* Operator */\n",
"body .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
"body .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
"body .cp { color: #BC7A00 } /* Comment.Preproc */\n",
"body .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
"body .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
"body .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
"body .gd { color: #A00000 } /* Generic.Deleted */\n",
"body .ge { font-style: italic } /* Generic.Emph */\n",
"body .gr { color: #FF0000 } /* Generic.Error */\n",
"body .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
"body .gi { color: #00A000 } /* Generic.Inserted */\n",
"body .go { color: #888888 } /* Generic.Output */\n",
"body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
"body .gs { font-weight: bold } /* Generic.Strong */\n",
"body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
"body .gt { color: #0044DD } /* Generic.Traceback */\n",
"body .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
"body .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
"body .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
"body .kp { color: #008000 } /* Keyword.Pseudo */\n",
"body .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
"body .kt { color: #B00040 } /* Keyword.Type */\n",
"body .m { color: #666666 } /* Literal.Number */\n",
"body .s { color: #BA2121 } /* Literal.String */\n",
"body .na { color: #7D9029 } /* Name.Attribute */\n",
"body .nb { color: #008000 } /* Name.Builtin */\n",
"body .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
"body .no { color: #880000 } /* Name.Constant */\n",
"body .nd { color: #AA22FF } /* Name.Decorator */\n",
"body .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
"body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
"body .nf { color: #0000FF } /* Name.Function */\n",
"body .nl { color: #A0A000 } /* Name.Label */\n",
"body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
"body .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
"body .nv { color: #19177C } /* Name.Variable */\n",
"body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
"body .w { color: #bbbbbb } /* Text.Whitespace */\n",
"body .mb { color: #666666 } /* Literal.Number.Bin */\n",
"body .mf { color: #666666 } /* Literal.Number.Float */\n",
"body .mh { color: #666666 } /* Literal.Number.Hex */\n",
"body .mi { color: #666666 } /* Literal.Number.Integer */\n",
"body .mo { color: #666666 } /* Literal.Number.Oct */\n",
"body .sa { color: #BA2121 } /* Literal.String.Affix */\n",
"body .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
"body .sc { color: #BA2121 } /* Literal.String.Char */\n",
"body .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
"body .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
"body .s2 { color: #BA2121 } /* Literal.String.Double */\n",
"body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
"body .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
"body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
"body .sx { color: #008000 } /* Literal.String.Other */\n",
"body .sr { color: #BB6688 } /* Literal.String.Regex */\n",
"body .s1 { color: #BA2121 } /* Literal.String.Single */\n",
"body .ss { color: #19177C } /* Literal.String.Symbol */\n",
"body .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
"body .fm { color: #0000FF } /* Name.Function.Magic */\n",
"body .vc { color: #19177C } /* Name.Variable.Class */\n",
"body .vg { color: #19177C } /* Name.Variable.Global */\n",
"body .vi { color: #19177C } /* Name.Variable.Instance */\n",
"body .vm { color: #19177C } /* Name.Variable.Magic */\n",
"body .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
"\n",
" </style>\n",
"</head>\n",
"<body>\n",
"<h2></h2>\n",
"\n",
"<div class=\"highlight\"><pre><span></span><span class=\"k\">def</span> <span class=\"nf\">three_block_tower</span><span class=\"p\">():</span>\n",
" <span class=\"sd\">"""</span>\n",
"<span class=\"sd\"> [Figure 10.3] THREE-BLOCK-TOWER</span>\n",
"\n",
"<span class=\"sd\"> A blocks-world problem of stacking three blocks in a certain configuration,</span>\n",
"<span class=\"sd\"> also known as the Sussman Anomaly.</span>\n",
"<span class=\"sd\"> Example:</span>\n",
"<span class=\"sd\"> >>> from planning import *</span>\n",
"<span class=\"sd\"> >>> tbt = three_block_tower()</span>\n",
"<span class=\"sd\"> >>> tbt.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> tbt.act(expr('MoveToTable(C, A)'))</span>\n",
"<span class=\"sd\"> >>> tbt.act(expr('Move(B, Table, C)'))</span>\n",
"<span class=\"sd\"> >>> tbt.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> tbt.act(expr('Move(A, Table, B)'))</span>\n",
"<span class=\"sd\"> >>> tbt.goal_test()</span>\n",
"<span class=\"sd\"> True</span>\n",
"<span class=\"sd\"> >>></span>\n",
"<span class=\"sd\"> """</span>\n",
"\n",
" <span class=\"k\">return</span> <span class=\"n\">PlanningProblem</span><span class=\"p\">(</span><span class=\"n\">init</span><span class=\"o\">=</span><span class=\"s1\">'On(A, Table) & On(B, Table) & On(C, A) & Block(A) & Block(B) & Block(C) & Clear(B) & Clear(C)'</span><span class=\"p\">,</span>\n",
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
" <span class=\"n\">goals</span><span class=\"o\">=</span><span class=\"s1\">'On(A, B) & On(B, C)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">actions</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'Move(b, x, y)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'On(b, x) & Clear(b) & Clear(y) & Block(b) & Block(y)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'On(b, y) & Clear(x) & ~On(b, x) & ~Clear(y)'</span><span class=\"p\">),</span>\n",
" <span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'MoveToTable(b, x)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'On(b, x) & Clear(b) & Block(b)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'On(b, Table) & Clear(x) & ~On(b, x)'</span><span class=\"p\">)])</span>\n",
"</pre></div>\n",
"</body>\n",
"</html>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"psource(three_block_tower)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**On(b, x):** The block **'b'** is on **'x'**. **'x'** can be a table or a block.\n",
"\n",
"**~On(b, x):** The block **'b'** is _not_ on **'x'**. **'x'** can be a table or a block.\n",
"\n",
"**Block(b):** Declares **'b'** as a block.\n",
"\n",
"**Clear(x):** To indicate that there is nothing on **'x'** and it is free to be moved around.\n",
"\n",
"**~Clear(x):** To indicate that there is something on **'x'** and it cannot be moved.\n",
" \n",
" Let us now define an object of `three_block_tower` problem:"
"threeBlockTower = three_block_tower()"
"Before taking any actions, we will check if `threeBlockTower` has reached its goal:"
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"print(threeBlockTower.goal_test())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we can see, it hasn't completed the goal. \n",
"We now define a sequence of actions that can stack three blocks in the required order. \n",
"The actions are then carried out on the `threeBlockTower` PlanningProblem.\n",
"The actions available to us are the following: MoveToTable, Move\n",
"\n",
"**MoveToTable(b, x): ** Move box **'b'** stacked on **'x'** to the table, given that box **'b'** is clear.\n",
"\n",
"**Move(b, x, y): ** Move box **'b'** stacked on **'x'** to the top of **'y'**, given that both **'b'** and **'y'** are clear.\n"
"solution = [expr(\"MoveToTable(C, A)\"),\n",
" expr(\"Move(B, Table, C)\"),\n",
" expr(\"Move(A, Table, B)\")]\n",
"\n",
"for action in solution:\n",
" threeBlockTower.act(action)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As the `three_block_tower` has taken all the steps it needed in order to achieve the goal, we can now check if it has acheived its goal."
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"print(threeBlockTower.goal_test())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It has now successfully achieved its goal i.e, to build a stack of three blocks in the specified order."
"The `three_block_tower` problem can also be defined in simpler terms using just two actions `ToTable(x, y)` and `FromTable(x, y)`.\n",
"The underlying problem remains the same however, stacking up three blocks in a certain configuration given a particular starting state.\n",
"Let's have a look at the alternative definition."
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
"text/html": [
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n",
" \"http://www.w3.org/TR/html4/strict.dtd\">\n",
"\n",
"<html>\n",
"<head>\n",
" <title></title>\n",
" <meta http-equiv=\"content-type\" content=\"text/html; charset=None\">\n",
" <style type=\"text/css\">\n",
"td.linenos { background-color: #f0f0f0; padding-right: 10px; }\n",
"span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }\n",
"pre { line-height: 125%; }\n",
"body .hll { background-color: #ffffcc }\n",
"body { background: #f8f8f8; }\n",
"body .c { color: #408080; font-style: italic } /* Comment */\n",
"body .err { border: 1px solid #FF0000 } /* Error */\n",
"body .k { color: #008000; font-weight: bold } /* Keyword */\n",
"body .o { color: #666666 } /* Operator */\n",
"body .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
"body .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
"body .cp { color: #BC7A00 } /* Comment.Preproc */\n",
"body .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
"body .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
"body .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
"body .gd { color: #A00000 } /* Generic.Deleted */\n",
"body .ge { font-style: italic } /* Generic.Emph */\n",
"body .gr { color: #FF0000 } /* Generic.Error */\n",
"body .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
"body .gi { color: #00A000 } /* Generic.Inserted */\n",
"body .go { color: #888888 } /* Generic.Output */\n",
"body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
"body .gs { font-weight: bold } /* Generic.Strong */\n",
"body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
"body .gt { color: #0044DD } /* Generic.Traceback */\n",
"body .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
"body .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
"body .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
"body .kp { color: #008000 } /* Keyword.Pseudo */\n",
"body .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
"body .kt { color: #B00040 } /* Keyword.Type */\n",
"body .m { color: #666666 } /* Literal.Number */\n",
"body .s { color: #BA2121 } /* Literal.String */\n",
"body .na { color: #7D9029 } /* Name.Attribute */\n",
"body .nb { color: #008000 } /* Name.Builtin */\n",
"body .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
"body .no { color: #880000 } /* Name.Constant */\n",
"body .nd { color: #AA22FF } /* Name.Decorator */\n",
"body .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
"body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
"body .nf { color: #0000FF } /* Name.Function */\n",
"body .nl { color: #A0A000 } /* Name.Label */\n",
"body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
"body .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
"body .nv { color: #19177C } /* Name.Variable */\n",
"body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
"body .w { color: #bbbbbb } /* Text.Whitespace */\n",
"body .mb { color: #666666 } /* Literal.Number.Bin */\n",
"body .mf { color: #666666 } /* Literal.Number.Float */\n",
"body .mh { color: #666666 } /* Literal.Number.Hex */\n",
"body .mi { color: #666666 } /* Literal.Number.Integer */\n",
"body .mo { color: #666666 } /* Literal.Number.Oct */\n",
"body .sa { color: #BA2121 } /* Literal.String.Affix */\n",
"body .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
"body .sc { color: #BA2121 } /* Literal.String.Char */\n",
"body .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
"body .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
"body .s2 { color: #BA2121 } /* Literal.String.Double */\n",
"body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
"body .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
"body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
"body .sx { color: #008000 } /* Literal.String.Other */\n",
"body .sr { color: #BB6688 } /* Literal.String.Regex */\n",
"body .s1 { color: #BA2121 } /* Literal.String.Single */\n",
"body .ss { color: #19177C } /* Literal.String.Symbol */\n",
"body .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
"body .fm { color: #0000FF } /* Name.Function.Magic */\n",
"body .vc { color: #19177C } /* Name.Variable.Class */\n",
"body .vg { color: #19177C } /* Name.Variable.Global */\n",
"body .vi { color: #19177C } /* Name.Variable.Instance */\n",
"body .vm { color: #19177C } /* Name.Variable.Magic */\n",
"body .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
"\n",
" </style>\n",
"</head>\n",
"<body>\n",
"<h2></h2>\n",
"\n",
"<div class=\"highlight\"><pre><span></span><span class=\"k\">def</span> <span class=\"nf\">simple_blocks_world</span><span class=\"p\">():</span>\n",
" <span class=\"sd\">"""</span>\n",
"<span class=\"sd\"> SIMPLE-BLOCKS-WORLD</span>\n",
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
"<span class=\"sd\"> A simplified definition of the Sussman Anomaly problem.</span>\n",
"\n",
"<span class=\"sd\"> Example:</span>\n",
"<span class=\"sd\"> >>> from planning import *</span>\n",
"<span class=\"sd\"> >>> sbw = simple_blocks_world()</span>\n",
"<span class=\"sd\"> >>> sbw.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> sbw.act(expr('ToTable(A, B)'))</span>\n",
"<span class=\"sd\"> >>> sbw.act(expr('FromTable(B, A)'))</span>\n",
"<span class=\"sd\"> >>> sbw.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> sbw.act(expr('FromTable(C, B)'))</span>\n",
"<span class=\"sd\"> >>> sbw.goal_test()</span>\n",
"<span class=\"sd\"> True</span>\n",
"<span class=\"sd\"> >>></span>\n",
"<span class=\"sd\"> """</span>\n",
"\n",
" <span class=\"k\">return</span> <span class=\"n\">PlanningProblem</span><span class=\"p\">(</span><span class=\"n\">init</span><span class=\"o\">=</span><span class=\"s1\">'On(A, B) & Clear(A) & OnTable(B) & OnTable(C) & Clear(C)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">goals</span><span class=\"o\">=</span><span class=\"s1\">'On(B, A) & On(C, B)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">actions</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'ToTable(x, y)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'On(x, y) & Clear(x)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'~On(x, y) & Clear(y) & OnTable(x)'</span><span class=\"p\">),</span>\n",
" <span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'FromTable(y, x)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'OnTable(y) & Clear(y) & Clear(x)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'~OnTable(y) & ~Clear(x) & On(y, x)'</span><span class=\"p\">)])</span>\n",
"</pre></div>\n",
"</body>\n",
"</html>\n"
],
"<IPython.core.display.HTML object>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**On(x, y):** The block **'x'** is on **'y'**. Both **'x'** and **'y'** have to be blocks.\n",
"**~On(x, y):** The block **'x'** is _not_ on **'y'**. Both **'x'** and **'y'** have to be blocks.\n",
"**OnTable(x):** The block **'x'** is on the table.\n",
"**~OnTable(x):** The block **'x'** is _not_ on the table.\n",
"\n",
"**Clear(x):** To indicate that there is nothing on **'x'** and it is free to be moved around.\n",
"\n",
"**~Clear(x):** To indicate that there is something on **'x'** and it cannot be moved.\n",
"\n",
"Let's now define a `simple_blocks_world` prolem."
"simpleBlocksWorld = simple_blocks_world()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before taking any actions, we will see if `simple_bw` has reached its goal."
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"metadata": {},
"output_type": "execute_result"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we can see, it hasn't completed the goal. \n",
"We now define a sequence of actions that can stack three blocks in the required order. \n",
"The actions are then carried out on the `simple_bw` PlanningProblem.\n",
"The actions available to us are the following: MoveToTable, Move\n",
"**ToTable(x, y): ** Move box **'x'** stacked on **'y'** to the table, given that box **'y'** is clear.\n",
"\n",
"**FromTable(x, y): ** Move box **'x'** from wherever it is, to the top of **'y'**, given that both **'x'** and **'y'** are clear.\n"
"solution = [expr('ToTable(A, B)'),\n",
" expr('FromTable(B, A)'),\n",
" expr('FromTable(C, B)')]\n",
"\n",
"for action in solution:\n",
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As the `three_block_tower` has taken all the steps it needed in order to achieve the goal, we can now check if it has acheived its goal."
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
"print(simpleBlocksWorld.goal_test())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It has now successfully achieved its goal i.e, to build a stack of three blocks in the specified order."
{
"cell_type": "markdown",
"metadata": {},
"source": [
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This problem requires us to acquire a carton of milk, a banana and a drill.\n",
"Initially, we start from home and it is known to us that milk and bananas are available in the supermarket and the hardware store sells drills.\n",
"Let's take a look at the definition of the `shopping_problem` in the module."
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
"outputs": [
{
"data": {
"text/html": [
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n",
" \"http://www.w3.org/TR/html4/strict.dtd\">\n",
"\n",
"<html>\n",
"<head>\n",
" <title></title>\n",
" <meta http-equiv=\"content-type\" content=\"text/html; charset=None\">\n",
" <style type=\"text/css\">\n",
"td.linenos { background-color: #f0f0f0; padding-right: 10px; }\n",
"span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }\n",
"pre { line-height: 125%; }\n",
"body .hll { background-color: #ffffcc }\n",
"body { background: #f8f8f8; }\n",
"body .c { color: #408080; font-style: italic } /* Comment */\n",
"body .err { border: 1px solid #FF0000 } /* Error */\n",
"body .k { color: #008000; font-weight: bold } /* Keyword */\n",
"body .o { color: #666666 } /* Operator */\n",
"body .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
"body .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
"body .cp { color: #BC7A00 } /* Comment.Preproc */\n",
"body .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
"body .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
"body .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
"body .gd { color: #A00000 } /* Generic.Deleted */\n",
"body .ge { font-style: italic } /* Generic.Emph */\n",
"body .gr { color: #FF0000 } /* Generic.Error */\n",
"body .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
"body .gi { color: #00A000 } /* Generic.Inserted */\n",
"body .go { color: #888888 } /* Generic.Output */\n",
"body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
"body .gs { font-weight: bold } /* Generic.Strong */\n",
"body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
"body .gt { color: #0044DD } /* Generic.Traceback */\n",
"body .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
"body .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
"body .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
"body .kp { color: #008000 } /* Keyword.Pseudo */\n",
"body .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
"body .kt { color: #B00040 } /* Keyword.Type */\n",
"body .m { color: #666666 } /* Literal.Number */\n",
"body .s { color: #BA2121 } /* Literal.String */\n",
"body .na { color: #7D9029 } /* Name.Attribute */\n",
"body .nb { color: #008000 } /* Name.Builtin */\n",
"body .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
"body .no { color: #880000 } /* Name.Constant */\n",
"body .nd { color: #AA22FF } /* Name.Decorator */\n",
"body .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
"body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
"body .nf { color: #0000FF } /* Name.Function */\n",
"body .nl { color: #A0A000 } /* Name.Label */\n",
"body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
"body .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
"body .nv { color: #19177C } /* Name.Variable */\n",
"body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
"body .w { color: #bbbbbb } /* Text.Whitespace */\n",
"body .mb { color: #666666 } /* Literal.Number.Bin */\n",
"body .mf { color: #666666 } /* Literal.Number.Float */\n",
"body .mh { color: #666666 } /* Literal.Number.Hex */\n",
"body .mi { color: #666666 } /* Literal.Number.Integer */\n",
"body .mo { color: #666666 } /* Literal.Number.Oct */\n",
"body .sa { color: #BA2121 } /* Literal.String.Affix */\n",
"body .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
"body .sc { color: #BA2121 } /* Literal.String.Char */\n",
"body .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
"body .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
"body .s2 { color: #BA2121 } /* Literal.String.Double */\n",
"body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
"body .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
"body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
"body .sx { color: #008000 } /* Literal.String.Other */\n",
"body .sr { color: #BB6688 } /* Literal.String.Regex */\n",
"body .s1 { color: #BA2121 } /* Literal.String.Single */\n",
"body .ss { color: #19177C } /* Literal.String.Symbol */\n",
"body .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
"body .fm { color: #0000FF } /* Name.Function.Magic */\n",
"body .vc { color: #19177C } /* Name.Variable.Class */\n",
"body .vg { color: #19177C } /* Name.Variable.Global */\n",
"body .vi { color: #19177C } /* Name.Variable.Instance */\n",
"body .vm { color: #19177C } /* Name.Variable.Magic */\n",
"body .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
"\n",
" </style>\n",
"</head>\n",
"<body>\n",
"<h2></h2>\n",
"\n",
"<div class=\"highlight\"><pre><span></span><span class=\"k\">def</span> <span class=\"nf\">shopping_problem</span><span class=\"p\">():</span>\n",
" <span class=\"sd\">"""</span>\n",
"<span class=\"sd\"> SHOPPING-PROBLEM</span>\n",
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
"<span class=\"sd\"> A problem of acquiring some items given their availability at certain stores.</span>\n",
"\n",
"<span class=\"sd\"> Example:</span>\n",
"<span class=\"sd\"> >>> from planning import *</span>\n",
"<span class=\"sd\"> >>> sp = shopping_problem()</span>\n",
"<span class=\"sd\"> >>> sp.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> sp.act(expr('Go(Home, HW)'))</span>\n",
"<span class=\"sd\"> >>> sp.act(expr('Buy(Drill, HW)'))</span>\n",
"<span class=\"sd\"> >>> sp.act(expr('Go(HW, SM)'))</span>\n",
"<span class=\"sd\"> >>> sp.act(expr('Buy(Banana, SM)'))</span>\n",
"<span class=\"sd\"> >>> sp.goal_test()</span>\n",
"<span class=\"sd\"> False</span>\n",
"<span class=\"sd\"> >>> sp.act(expr('Buy(Milk, SM)'))</span>\n",
"<span class=\"sd\"> >>> sp.goal_test()</span>\n",
"<span class=\"sd\"> True</span>\n",
"<span class=\"sd\"> >>></span>\n",
"<span class=\"sd\"> """</span>\n",
"\n",
" <span class=\"k\">return</span> <span class=\"n\">PlanningProblem</span><span class=\"p\">(</span><span class=\"n\">init</span><span class=\"o\">=</span><span class=\"s1\">'At(Home) & Sells(SM, Milk) & Sells(SM, Banana) & Sells(HW, Drill)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">goals</span><span class=\"o\">=</span><span class=\"s1\">'Have(Milk) & Have(Banana) & Have(Drill)'</span><span class=\"p\">,</span> \n",
" <span class=\"n\">actions</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'Buy(x, store)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'At(store) & Sells(store, x)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'Have(x)'</span><span class=\"p\">),</span>\n",
" <span class=\"n\">Action</span><span class=\"p\">(</span><span class=\"s1\">'Go(x, y)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">precond</span><span class=\"o\">=</span><span class=\"s1\">'At(x)'</span><span class=\"p\">,</span>\n",
" <span class=\"n\">effect</span><span class=\"o\">=</span><span class=\"s1\">'At(y) & ~At(x)'</span><span class=\"p\">)])</span>\n",
"</pre></div>\n",
"</body>\n",
"</html>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**At(x):** Indicates that we are currently at **'x'** where **'x'** can be Home, SM (supermarket) or HW (Hardware store).\n",
"**~At(x):** Indicates that we are currently _not_ at **'x'**.\n",
"**Sells(s, x):** Indicates that item **'x'** can be bought from store **'s'**.\n",
"\n",