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:

 

  1. Direct Truckworld interface
  2. Picking up objects
  3. Putting objects into containers
  4. Refueling
  5. Traveling

 

 

Direct Truckworld interface

 

    1. The command START initializes the Truckworld
    2. The command STOP terminates the Truckworld

 

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
truckworld-execution.lsp

 

(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
((KIND ROCK) (COLOR GREEN))
The function returns the positions of all objects at that location that match the input properties according to the current percept.

 

 

 

(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

 

  1. You can propose any extension to the language you want for extra credit. Just check with us first.
  2. The current interaction with the command processor is quite primitive: if something goes wrong, it simply returns an error symbol. Enhance this capability by making the command processor explain why it couldn't execute a command (i.e. which precondition(s) were violated).
  3. A common form of execution error is that an object description does not uniquely identify an object. For example, (PICK UP THE RED GLASS) might be ambiguous because there are two red glasses. The command processor should print a message to that effect, prompt for information from the user that would determine which one, and proceed with execution.
  4. It is fairly easy to extend the language to accept compound commands like:
    (PICK UP THE RED GLASS AND RECYCLE IT)
    (PICK UP A GLASS THEN GO TO THE WAREHOUSE)
  5. Another minor cosmetic improvement would be to change the interface so it accepts punctuated character strings as input:
    "Pick up a glass, then go to the warehouse."
    Define an alternative version of
    execute-command that accepts a string, parses, and executes it.
  6. It turns out that in this version of the world, if you SET a glass, the glass will break. Extend the command syntax to allow glasses to be broken. It should be flagged as an error (infeasible) to set any object other than a glass or a fuel-drum dispenser, and if the user tries to SET a glass that is already broken, you should generate an appropriate warning message.
  7. Extend the functionality so the command processor has to "think" about how to execute a command. For example, (TAKE ALL THE GLASSES TO THE DEPOT) might require several actions, and in fact could be looked at as a problem-solving task. So you could take the command, translate it into a symbolic goal like (FORALL (GLASS ?G) (AT ?G DEPOT)), call UCPOP or Graphplan which would produce solution actions, then execute the resulting plan. (Warning! This one is very difficult and very open ended, so it is not for the faint of heart!)