# Artificial Intelligence Programming

ICS 361

## Assignment #5 - AKA Course Project Creating a Recycling Softbot in Common Lisp

This assignment is worth 200 points.

Your assignment is to design, implement, test, and report results on the project described below.

• Start with the simple Vacuum cleaner agent code provided by Norvig & Russell.
• Reference the VacuumWorld slides on Laulima (VacuumWorld.pdf under lectures)
• Open http://aima.cs.berkeley.edu/lisp/ . Then download the file code.tar.gz and unzip it.
• Alternatively, a local copy of the unzipped code is here.
• Documentation for the code is at http://aima.cs.berkeley.edu/lisp/doc/overview.html
You will only need to load the utilities and agents subsystems of the AIMA code. Start with and modify the grid environment and vacuum agent code, you do not need to re-write the parts of the code that are available.
• Output from the simple Reflex vacuum is here. The lines with gc represent garbage collection and can be ignored. The run was not optimized for speed or space use.

Your GOAL is to create a softbot to collect bottles and cans and put them into a recycle bin.

The robot can carry a mazimum of 1 can and 1 bottle at the same time. Cans and bottles are released separately into the Recycle bin (Rb).

What actions will your robot need to complete its task? Explain them in your report. What strategies do you use to clean the room? Find the Recyclebin (Rb)? Minimize the number of moves? Explain these in your report.

• (25 p) Printout. Change the print function so that the entire world is not printed out at every move. Select to print the world every X moves and/or when something significant happens. It is a good idea to print out the percepts and actions at each step, however.
• (10 p) Starting Location. Your robot always starts in the LOWER left cell of the room, represent it with a capital R (instead of the V, used for the vacuum).

UPDATED The format for these files is shown in Room specification format. The file format is:
x and y (or Row and Column) size of the room
x and y (or Row and Column) position of the Recycle bin.
n pieces of furniture specified by opposite corners of a rectancle (X Y X Y or R C R C)
m bottles and cans, each on a line starting with B or C and followed by the coordinates.

The maximum legal size of a room is 20 by 20 squares. If a file has a larger room specified, it is an error.
(Read in scenario files for different sized rooms, recycling loads and obstacle locations. Obstacles are specified by the two opposite corners of a rectangle. Your initialization program must block all cells in that rectangular area.

• (20 p)You must check for errors in the input file.
Some example room files can be found here. Note that some examples may be bigger than you are required to handle for this assignment.
• Create the recycling bin (Rb) in the specified cell.
• More files will be added shortly.

For development purposes, you may create the cans/bottles randomly instead of reading them in from a room specification file. The vacuum world has a dirt factor which randomly distributes dirt in the cells. You can modify this so that this number represents the total number of items that need recycling in the room. They will be distributed randomly in the room like the dirt is in the vacuum world. You may remove or ignore the direction state indicator in the vacuum code. Do not print it out in the room layout grid.

• (25 p) More/better sensors. There are 2 choices for sensors, an additional 4 sensors or an additional 8 sensors to view the surrounding cells.
```NEW: FORMAT for sensor input:
Difference between vacuum sensors and robot's sensors.
NO sensor for home
ADD binary sensor for Rb in current cell (separate from contents)
CHANGE  input for current square either  B or C or empty.

ADD LIST of outer sensor readings (4 or 8) Sensor order should be 1=
up, 3 = right, 5= down, 7 = left.  With even numbers 2-8 for the sensors
inbetween those 4.  Sensors return one of the values below

```
• Detect if there is a can or bottle in the current cell.
• Determine if the recycling bin (Rb) is in the current cell.
We will limit the problem to a maximum of 1 Bottle OR 1 Can per cell. This sensors return C or B for can and bottle respectively. Rb will be identified with a yes/no sensor.
• (4 extra sensors option) detect blockages (furniture) and the edges of the room in the four cells Up, Down, Left and Right. These extra sensors aren't able to count cans in the surrounding cells. Instead they return one of the following values: clear, blocked, or messy (not clear or blocked). Blocked means a wall or a piece of furniture while messy means 1 or more bottles/cans.
• (8 extra sensors option) have the 4 sensors above, plus 4 sensors that can detect blockages in the 4 cells diagonal from the current cell, UpLeft, UpRight, DownLeft and DownRight. NOTE: you can only sense the diagonals if ONE or BOTH of the adjacent cells are open. For example, if Up and Right are blocked and Down and Left are clear, you can detect the cells at ULeft, DLeft, and DRight, but not URight. If a cell on the diagonal can't be accessed, the softbot returns nil for that cell.
• (25 pt) Enhance your robot's ability to move - there are 2 choices:
1. (4 move option) 4 directions - up, down, left, right or
2. (8 move option) 8 directions (UDLR and diagonals ULeft, URight, DLeft and DRight).
Note that diagonals are only accessable if one or both of the adjacent cells are unblocked (see sensors above).
• (25 pt) Create an internal map where the robot keeps track of its explorations of the world. This map is SEPARATE from the robot's environment. The robot will need to discover the size and shape of the room as well as the cell where the recycling bin is located, all obstacles and cans/bottles in the room. Keep track of the number of moves it takes you to recycle all cans/bottles in the room. (goal-based agent) Write about the results in your report.
• (50 p) Search for recyclables, the Rb, and find out the size of the room. Keep a count of the number of moves taken.

Create several different rooms and test your robot's performance with different numbers of cans. Is a particular strategy useful to find the recycling bin early in your search?

### Competition

Your softbot will compete with others during the last week of class.

There are 3 levels of competition. There are 2 choices for robot sensors (see sensors above). There are 3 levels of competition, 1 hand (can or bottle) Easy, 2 hands (cans or bottles in either) Medium and 1 Can hand + 1 Bottle hand Hard. Programs in each competition level will receive 50 bonus EC assignment points. The runner-up will receive 25 points and 3rd place 10 points.

Turn in your code, transcripts of testing and running it, and a report on your solution/algorithms and results.

Back to the course homepage.

(c) N. E. Reed, 2005-2016