CSE630 Homework 1: Intelligence in general, Designing Intelligent Agents
EXTENSION: Due to the tornado warning, hail, and power outages on October 4th, I'm granting a 24 hour extension.
Due: October 5th at 11:59 PM
1 point late
penalty for each minute late
Part 1: Intelligence and Rationality
(Note: Your responses to these questions must be submitted
electronically. Please see the submission
instructions below.
- (10 points) Define in your own words: a) intelligence, b) artificial intelligence, c) agent.
- (10 points) Imagine you had a refrigerator that could order food for you from the market. How could you determine if the refrigerator is rational?
- (10 points) Suppose you are interacting with another person in an online chat forum. A mischievous friend has told that person that you are a very advanced chatbot, so now you must try to prove that you are in fact a person rather than a chatbot. All you have available for communicating is a text-based display. How would you go about it? Would your argument focus on reasoning capabilities or sensory abilities?
- (10 points) Develop a PEAS description of the task environment for (a) a robotic hospital delivery tray and (b) an autonomous Mars rover.
- (10 points) Read the following stories from the Darwin Awards
website located here (Warning: Some Darwin award stories contain graphic accounts of messy self-inflicted wounds. Stick to only the stories below if you are squeamish; you can substitute other stories if you wish) :
- Freeway Dangler (2005)
- Spy vs. self (2004)
- Slaughterhouse Robbery (2003)
The agent described in each of these stories has done something
irrational, but using what you have learned in this class, you can
give a more precise reason for why the action was irrational. For
each of these three stories, identify the point of failure that
prevented each of these agents from completing his task in terms of
the general agent design diagram of Figure 2.13. Was the fatal
mistake a failure to correctly assess what the world is like now (in
other words, a failure to translate perceptions into knowledge), a
failure to correctly assess which actions the agent could perform
given the state of the world, or a failure to judge 'what will the
world be like if I do action A'?
Part 2: Build a Simple Agent
Implement a simple agent in the programming language of your
choice. The agent's task will be remote exploration, such as a very
simple version of the Mars Rover. The agent can move from place to
place and pick up soil samples for analysis. The purpose of this
assignment is for you to become familiar with the difference between a
simple reflex agent and a reflex agent with state.
You may write your agent from scratch or utilize the objects in the code repository
provided with the textbook (with this caveat).
I recommend that you draw on the pseudocode in the book to help design
your agent. If you use the step names in the book such as
Interpret-Input and Rule-Action (p. 47), it will be easy to extend
your agent with new capabilities for future assignments.
A simple reflex agent (25 points)
Build a reflex agent that probes the soil at its current location, and
collects a soil sample only if the soil composition matches a
predefined criteria defining target compounds. The soil's composition
is represented as an integer number, so the perception that the agent
receives from its soil probe will be a numeric value. This agent can
perform two possible actions: GRAB and NOOP. At each time interval, it
should probe the soil, and either GRAB a sample if the probe value is
a target compound, or NOOP if it is not (actually it will not be
grabbing anything, it just writes the word 'GRAB' out to stdout). We
will pretend that the agent is being moved around by remote control,
so it does not need actions for moving. To keep things simple, the
criteria for collecting a sample is if the perception is greater than 5.
In other words, the agent should GRAB if it
perceives 6, 7, 8, ..., and should NOOP if the percept is any other
number.
Input:
The percepts will be provided to the agent in a file, with one
perception per line, and the perceptions will be represented as
integers between 0 and 20. The agent should accept an input file from
stdin so that we can test the agent with different input files. The agent needs to
run at the command ReflexRover and be prepared to read the input file
from standard in (without the parens around the
file name of course):
> ReflexRover < (filename)
A sample input file is provided here.
We have provided a function that reads the input file and provides
percepts to the agent. The code is available in
C++, Perl, and Java.
Output: The agent should output the percept it received at each time step and
the action it chose to perform. Output should be to stdout in exactly this format:
Perceived: X Action: (action)
An example output sequence is:
Perceived: 1 Action: NOOP
Perceived: 7 Action: GRAB
Perceived: 0 Action: NOOP
Perceived: 6 Action: GRAB
Grading: To receive full credit on this assignment, your program must
have a function called SimpleReflexAgent(int percept) that returns an
action, and the output produced much be appropriate given the input
file we will specify for the agent when we test your program.
A reflex agent with state (25 points)
Now we will extend the
agent's behavior to be more autonomous by choosing its own movements,
but the agent must choose its movements judiciously to avoid
obstacles. The obstacles will be sensed using a vision sensor. We
also want the robot to conserve energy, so it should make its best
attempt to only visit each location once (if possible) and should only
pick up each soil compound if it doesn't already have a sample of that
compound. You should pick up all samples you don't have, not just the ones greater than five.
Once again, writing the agent function to comply with the
pseudocode in Figure 2.12 will help when it comes time to modify the
agent's abilities or perceptions in future assignments.
The robot still has the soil probe perception from the first part of
this assignment. In addition, to plan the agent's movements, we will
add a vision sensor that tells the robot whether the direction the
camera is currently facing is CLEAR, meaning that the robot can move
onto that position, or BOULDER, in which case the robot cannot move
onto that grid position. Since the robot might damage itself running
into the boulder, we want the robot to look at each location before
attempting to move there. The robot must choose the direction to point
the camera using the actions LOOKNORTH, LOOKSOUTH, LOOKWEST, LOOKEAST.
The visual percept received by the agent depends on the direction the
camera is pointing. For example, if the robot is at grid position 1,1
and looks EAST, the robot will see whether square 2,1 is clear or
not. The agent should only move onto grid positions that are CLEAR.
Locations are descretized into a grid of x,y coordinates. The
grid has only 2 rows (a top and bottom location) in
each column. The Southern-most row is row 1 (y=1), and the
Westernmost column is column 1 (x=1). The agent's movement actions are:
GONORTH, GOSOUTH, GOEAST, GOWEST, in addition to the GRAB
and NOOP actions from before.
Beginning from (1,1) -- a location that you hard-code -- the robot should
traverse the grid and collect rock samples from each CLEAR position
only when it perceives a compound that it has not previously collected.
You should traverse the grid methodically, for example start at
the south end of the grid and proceed by exploring each row, then
moving north.
Since the agent now has two sensors, the percept for each time step
will now be a 2-tupple containing the number for the soil compound
located at the robot's present position, and whether the direction
the robot is looking is CLEAR or BOULDER.
If the agent looks toward a
direction that is outside of the defined grid (such as position
(1,6) in the example), it will SEE a NULL.
Input
The input file for the agent will contain a description of a grid with
either B (boulder) or a numeric soil composition in each position.
Each row of the grid will be described on a separate line in this
format:
row number,left position C=clear/B=boulder,left soil
compound, right C=clear/B=boulder, right soil composition
A
sample input file is provided
here
. Once again, we have provided a function that reads the
input file and provides percepts to the agent. The code is available
in C++, Perl, and Java.
Here's a map corresponding to the grid in the sample input file:
--------------------------
| B | 4 | B | 1 | 7 |
--------------------------
| 0 | 1 | 13 | 13 | B |
--------------------------
The corresponding positions are:
-------------------------------
| 1,2 | 2,2 | 3,2 | 4,2 | 5,2 |
-------------------------------
| 1,1 | 2,1 | 3,1 | 4,1 | 5,1 |
-------------------------------
The agent should run with the command-line command:
> StateRover < (filename)
Output
The output should include the percept at each time step and the action
chosen, as well as the position of the agent in each time step,
written to stdout in exactly this format:
Position:
Perceived: Action: (action), as well as a summary
line showing how many compounds were collected and how many moves were
made.
An example output sequence might be:
Position: <1,1> Perceived: <0,NULL> Action: LOOKNORTH
Position: <1,1> Perceived: <0,BOULDER> Action: LOOKEAST
Position: <1,1> Perceived: <0,CLEAR> Action: GOEAST
Position: <2,1> Perceived: <4,CLEAR> Action: GRAB
Position: <2,1> Perceived: <4,CLEAR> Action: LOOKWEST
Position: <2,1> Perceived: <4,CLEAR> Action: LOOKNORTH
...
Total Compounds Collected: 1 Total Moves: 1
Grading:To receive full credit on this assignment, your program should include
an agent function called ReflexAgentWithState(percept) that returns an
action.
Submission instructions:
Write up all of your answers to the
questions (2 through 6) in a text editor so that it can be submitted
electronically. Put that file as well as your two programs, and ONLY those files, in a
directory called hw1, and use the submit command to send
the files to the grader. The syntax of the submit command is:
> submit c630aa lab1 hw1
For the code, you should turn in either
- An executable
version of your program along with the source code.
- If your
program is written in an interpreted language, such as perl, lisp or
python, you can turn in just the source. In that case, make sure to
use a standard file extension so that we can determine how to run your
program, for example if the assignment says to name your executable
ReflexRover, but you wrote it in perl, name it ReflexRover.pl.
It is to your advantage to give the grader explicit instructions on
how to run your code. I would recommend leaving a README file with
examples of command lines used to run your code.
You can learn about using the submit command by typing man
submit at a unix command prompt. If you cannot get the
submit command to work, you can email your files to the grader,
but please don't use this option unless you're having trouble
with submit.
We will test your program on the CSE dept unix computers, so make sure
that the program you turn in is built to run on Solaris. Don't depend
on cross-platform language implementations, you should make sure your
code runs on the CSE dept Solaris system. If your program doesn't
execute successfully, we will not attempt to recompile it or otherwise
correct the error. Your program will be graded solely on whether its actions are
appropriate to the inputs we supply in our testing, not on your programming style or design sophistication.
Code Repository Disclaimer
The code repository provided by
the textbook authors is most likely very reliable code, however, be
warned that I haven't tested it and don't guarantee that it will work
as described. If you decide to use code from the repository, don't
expect your instructor or the grader to debug it for you.
Also, any
code you use from the repository should be clearly credited. Do not
make it appear to be your own work.