University of Washington
Department of Computer Science and Engineering

CSE473-Artificial Intelligence

Winter 1998

Problem Set #0.

Assigned January 5, 1997

Not handed in.

LISP Warm-up and Introduction to the Truckworld

The purpose of this assignment is to get you accustomed to using the LISP/PC environment, to load and start the Truckworld simulator both under manual and program control, and to write some simple programs that manipulate the Truckworld agent's sensors and effectors.

All the code we ask you to write in this assignment is already available, so you can look at it if you get stuck. Look in the folder

U:\COURSES\CSE473\PS0

All file references for the Truckworld are relative to the directory

U:\COURSES\CSE473\TRUCKWORLD

The first thing to do is load and execute the Truckworld simulator

 

  1. Start LISP, and load the Truckworld simulator. You may do this by choosing the "Load image" option from the "File/Images" sub-menu. Then, load the image file "U:\COURSES\CSE473\TRUCKWORLD\TRUCKWORLD.IMG"


  2. Now you are ready to start the simulator. You have several options when you run it, including
  3. The world defines what locations there are, what objects are at each location, how locations are connected, and lots of other properties about the world and the agent (truck). Notice in the function definition for run-demo (in loader.lsp), for example, that it uses a file
    demo-world.lsp that defines a world. You can look in the Truckworld subdirectory worlds to see what world definitions are available.

    We will be interested in two worlds, demo-world and 473-collection-world. The first corresponds to the Truckworld User Guide document you have, so you will use that in conjunction with the documentation. The second is a simpler world, which we will use to build an automated garbage-collector agent.


  4. First try running the demo world by executing the function (run-demo). This will load the demo-world, and start the simulator. A Truckworld displayer window should appear, and you should see a command prompt like TRUCKWORLD>. Follow the user guide and learn how to use the primitive Truckworld commands to do the following:


  5. The next thing to try is to use a different command processor. The command processor takes Truckworld commands from some source, sends them to the simulator, and returns status and sensing information. You used the interactive command processor when you ran the demo world. It was designed so a person could interact directly with the simulation, enter commands and view the results. However, it is often the case that a program rather than a person will control the simulator. In that case it is more convenient to communicate with the simulator using function calls: you call a function to send a command to the simulator, and the function's return value conveys status and sensing information.


  6. Try running the demo world again, but this time use the functional command processor. Notice that the function run-demo takes a keyword argument specifying the command processor, and the default is the interactive command processor. So instead, run the demo world as follows:
    (run-demo :command-processor 'friendly-functional-cp)


  7. When you run the demo world like that you should see the Truckworld displayer window, but this time you will not see the TRUCKWORLD> prompt. You will instead make function calls to the simulator. For example, to move ARM-1 outside, you would make the following function call:
    (ffcp-execute '(ARM-MOVE ARM-1 OUTSIDE))

    and you should see the arm move in the displayer window. Experiment again until you can do the same commands as above, but this time through function calls.


  8. Now you are ready to explore the collection world. The world file name is

    473-collection-world.lsp

    and there is a function (run-collection-world) that starts the simulator.


  9. The agent's main task in this world is to pick up and "recycle" objects, namely garbage, glass, and empty fuel drums. The agent also needs to travel from location to location, and refuel itself when necessary. Several aspects of the world (the placement of glass and garbage, and the connectivity of the graph) are randomly generated, so the agent also needs to use its sensors to keep track of the world's state. You should familiarize yourself with the collection world so you can:


  10. You have no doubt learned by now that getting the Truckworld agent to do anything using primitive actions can be tedious. On the other hand, much of what it does is quite regular, so we should be able to build some higher-level functions that make it easier to build common behavior patterns. Using the function ti-execute-commands in truckworld-interface.lsp write the following functions:
  11. Test your functions in the Truckworld, making use of the functions in truckworld-interface.lsp for starting, stopping, and executing commands in the simulator.

    Look in the file command-demo.lsp (in the ps0 directory) for a couple of examples of high-level commands if you get stuck, or just look at ps0.lsp which contains a sample solution.