(load "/Accounts/courses/cs327/aima/aima.lisp")
This loads the utilities that come with our textbook, Artificial Intelligence: A Modern Approach (AIMA).
Next, you should copy the Vacuum-World code into whichever directory you are doing your Lisp programming. Here is one example:
cp /Accounts/courses/cs327/vacuum/vacuum.lisp ~
The "~" is shorthand for your own home directory.
You can now further copy or modify this program at will.
(load "vacuum.lisp")
You can then run the environment by typing
(run-vacuum 5 7) ; Put whatever numbers here you like
where 5 is the size of the x-axis, and 7 is the size of the y-axis. (Try varying these). You should then see a diagram of Vacuum-World, with the agent indicated by an "A", and dirt indicated by "#". Every time you press the Enter key, the agent will suck up dirt if there is some in the current position, or move forward in the direction in which the agent points. Above the grid, the recent percept list and action taken are shown. The percept list contains three positions:
(bump-sensor dirt-sensor home-sensor)
bump-sensor is T if the agent has just bumped into a wall.
dirt-sensor is T if there is a piece of dirt underneath the agent.
home-sensor is T of the agent is in its home location (bottom left).
If you continue to press Enter, the agent will slide up the left hand side of the room, then back down the left side again until it reaches its home position again. For more information on Vacuum-World, checkout out Problems 2.7-2.12 on page 57 in your text - I've modelled this Vaccum-World closely after the ideas presented there. The performance measurement, for example, is the same as that contained in 2.9.
3. Copy the file "vacuum.lisp" to "vacuum_state.lisp". Again change the function choose-action (and other aspects of the Lisp code if necessary) to add some form of internal state to the agent so that it performs as close to perfectly rational as you can. You may not, however, change the parameters of choose-action to be anything other than the current percept. Giving the agent a birds-eye view, for example, is against the rules. It may not utilize any variables that exist in the external environment, such as (x,y) location or the like or size of the environment. It can build an internal view, however, based on what it has seen so far. Is the task environment:
> (load "/Accounts/courses/cs327/aima/aima.lisp")
> (load "vacuum_reflex.lisp") ; similarly with vacuum_state
> (run-vacuum 3 7) ; or whatever values I choose
You should also turn in a flat file called vacuum.txt, which contains the answers to all questions asked above.
Q: How do I get the program to not make me hit Enter after every
move?
A: Comment out the function read-line inside the function display-environment.