University of Washington
Department of Computer Science and Engineering
CSE473–Introduction to Artificial Intelligence
Winter 1998
Problem Set #4
Assigned February 25, 1998
Due March 13, 1998
Natural Language Processing: A Truckworld Command Processor
The Basic Idea:
You will write a natural language command processor that will take commands (lists of symbols) as input, will parse the command and determine whether it is feasible. If so, it will execute the command in the Truckworld. The interface should look like this:
(execute-command '(put the green rock in bay one))
and the return value will be one of the following:
:BAD-SENTENCE
if the sentence could not be parsed
:INFEASIBLE-COMMAND
if the sentence makes sense but the command could not be executed
:OK
if the command could be executed. In this case you will also execute it in the Truckworld
Notice that the input is a (non-nested) list of symbols that contains no punctuation.
The World:
This is the geography of the world, and your solution program can rely on the fact that there will be three locations, with these names, and connected as in the diagram above. I won't tell you about what objects are at what positions at these locations, since you can discover that by exploring the Truckworld, and your solution should not depend on the exact configuration of objects anyway. You can count on the following facts about any world, however:
Commands:
You must process commands in the following groups:
Direct Truckworld interface
Picking up objects
The basic command will be of the form
[USE arm-specifier TO] PICK UP object
PICK UP object [USING arm-specifier]
where
object is a phrase that uniquely identifies an object. At most one arm specifier is allowable. You should define GRASP as a synonym for PICK UP. To be feasible, the object description must refer to exactly one object (subject to an arbitrary choice, as in "A RED GLASS"). That object must be somewhere that can be reached from the truck's current location, the arm (if specified) must not be holding anything, and the object must be graspable. You must also support the IT pronoun (see discussion below), so the following sentences are also syntactically valid, for example:
PICK IT UP USING ARM 1
GRASP IT
The IT Pronoun
In most cases, the word
IT can refer to an object. It means "the object that was manipulated in the last command." For example, "it" might be the last object picked up, or put down, or the fuel drum used for refueling. If the last command was a travel command, the IT pronoun becomes undefined. Note that in PICK UP and PUT DOWN, the IT pronoun changes the syntax of the sentence (IT goes before UP or DOWN).
Putting objects down
The basic command is
PUT DOWN object [position-specifier] [IN container]
where
container could refer to a cargo bay or to a recycler and position-specifier identifies a position in that container. This could be "AT position", or "NEXT TO object". DROP should be synonymous with PUT DOWN. As before, the object may come before or after the DOWN. Omitting the container means put the object down outside at the current location. Omitting the position means put down the object at any empty position in the container. Preconditions for this action include: object can be resolved to a single object, if the position-specifier is included, the container cannot be a recycler, the position must be empty, the container must be a valid container, the object must be held by one of the arms.
Again, the
IT pronoun is available, so the following sentences are syntactically valid:
PUT IT DOWN
PUT IT DOWN NEXT TO THE RECYCLER
Refueling
There are two forms of the
REFUEL command:
REFUEL USING [arm-specifier AND] object
USE [arm-specifier AND] object TO REFUEL
where in either case the object described must describe a full fuel drum. The only precondition for this command is that the arm chosen must not currently be holding anything, unless that object is the fuel drum in question. As always, the
IT pronoun is on hand:
USE IT TO REFUEL
Traveling
The two commands are
TRAVEL TO location-name
GO direction
In the first case, the
location-name must be directly accessible to the truck's current location. In the second case, there must be a road going in the specified direction.
Interface Provided
We will provide you with the following interface to the Truckworld:
(ti-start-simulator)
(ti-stop-simulator)
The usual start and stop.
The following commands are part of the "truckworld execution" subsystem defined in the file
(tex-sense)
This function senses the world and sets the current percept. The current percept will be used in the find-objects function below. It is up to you to keep the current percept current. That is, you should re-sense the world every time a command execution changes it.
(tex-find-objects :container container :properties property-list)
The container is either
:OUTSIDE, :BAY-1, :BAY-2, :ARM-1, or :ARM-2 and property-list is a list of attribute-value pairs, for example
(tex-find-empty-position :container container)
The location is as above. This function searches the current percept, and returns a vacant position at the location if one exists, or NIL otherwise.
(tex-pickup :arm arm :container container :position position)
Container refers to the current container of the object, either :OUTSIDE, :BAY-1, or :BAY-2
(tex-putdown :arm arm :container container :position position)
The arm must be currently holding an object. Put it down at position position in the container, which is :OUTSIDE, :BAY-1, or :BAY-2
(tex-put-inside :arm arm :container container :position position)
The arm must be holding an object. Put that object down inside the container object located at the position in the container.
(tex-set-object :arm arm :container container :position position :value value)
The arm must not be holding an object. Set the object at the specified container/position location to the specified value.
(tex-pour :arm arm)
The arm must be holding a vessel (an object that contains fluid). The object's contents are poured into the truck's fuel tank.
(tex-travel :direction direction)
Travel in the specified direction.
Extra Credit