PS#1 Solution

Note that this solution is not the perfect solution. Many of you turned in solutions that improve on this one in one way or another. By the same token some of your solutions may not have gone as far as this one in some parts. Both of those situations are fine. This is simply a well-written solution to use as a reference for understanding PS#1.

This file acts both as and index to the PS#1 solution and as the readme for the solution.

The files included in this solution are (files in italics were changed)

agent.lsp
Added a keyword argument "behavior-mode" to RUN-AGENT, saying how behaviors are to be chosen. Options are:
:DECLARATION-ORDER
choose first applicable
:NAME-ORDER
choose first name on *BEHAVIOR-ORDER*
:RANDOM
choose randomly among applicable
Added a variable LAST-PERCEPT in the loop body. Every time after perception but before behavior execution, check to see whether the two are EQUALP. (This assumes the sensor will return the objects and their attributes in the same order each time around.)

Finally, added a function "test-bomb" for trying out extended world related behaviors.

behavior-definition.lsp
Added the variable *behavior-order* to control :NAME-ORDER operation. Also made appropriate changes to "choose-behavior" to support the two new run modes.
behavior-forms.lsp
Set up the variable *behavior-order* with appropriate values (for testing).

Added several new behaviors to deal with glass recycling in the extended world.

debug.lsp
No changes
loader.lsp
Changed the *default-directory* appropriately.
load-utils.lsp
No changes
macrop-definition.lsp
Altered match-macrop and added expand-out to support recursive macrop expansion. Note that macrops may be nested arbitrarily deeply but 1) loops will not be detected and final forms are only guaranteed to be truckworld commands for well-formed macrops and well-formed input.
macrop-forms.lsp
Added a number of macrops (including recursive macrops) to support the bombs-away extended world.
match.lsp
No changes
percept.lsp
 
Altered to support perception of an object's state (such as broken/unbroken).
truckword-interface.lsp
No changes

Special instructions

Note that the *behavior-order* variable is set up only for testing. It will need to be altered for production runs.

Use test-bomb to try out the bomb-related behaviors.

Use (run-agent :behavior-mode :RANDOM) to try out randomness.