Assignment 1: Problem Formulation and Basic Search
CSE 415: Introduction to Artificial Intelligence
The University of Washington, Seattle, Autumn 2026
horizontal bar
Due Monday, October 12, at 11:59 PM. You may do this assignment either individually or in a partnership of two. If you work in a partnership, you'll be turning in one set of files for the partnership, rather than two sets of files. You are permitted to use AI as a coding assistant in this assignment; however, we recommend that you read the guidelines for prompting (see the ED post about prompting guidelines under "General") and do the record-keeping so that you can complete the prompting-related part of the report. The report also includes the general sections described on the Assignment Reports page, including the models and tools you used for agentic programming.
 
Introduction

This assignment is the first of two assignments on state-space search in single-agent, deterministic environments. Later we will consider multi-agent search in environments with stochastic dynamics. In this assignment we introduce a framework for the classical theory of problem solving, and we implement and compare basic ("blind") search algorithms. In Assignment 2, you will build on the code from this assignment to explore heuristic search.

After doing the coding and executions described below, you'll make entries in a short report document A1Report.pdf that you'll submit along with your code.

Problem Formulation and Blind Search

This assignment is about basic problem formulation and basic search algorithms.

1. First, download the starter code for this assignment. Unzip it with a utility such as Windows Compressed Folders, etc.

2. Examine each of the two problem formulation files provided. One is the Humans, Robots and Ferry problem. The other is the Towers of Hanoi problem. An additional file is provided, Farmer_Fox.py, and you will be writing one new problem formulation in that file.

In the given formulation files, pay particular attention to how the State class is defined and how the operators are established. We will be talking about this code in class.

3. An interactive solving client is provided. This is implemented in the file Int_Solv_Client.py. Optional but recommended: Try running the client with Towers of Hanoi by using the following command in a Linux, Darwin (via the Terminal app in MacOS), or WSL (via Windows Subsystem for Linux under Windows 11) command shell. To do this, issue the command:
python Int_Solv_Client.py TowersOfHanoi 3
If you are not comfortable working in Linux, Darwin, or WSL, you may wish to simply create a working folder with the Interactive Solving Client in it, and all the problem formulation files in it, and edit the importing code of the Interactive Solving Client so that it simply imports the problem formulation of your choice, and then run the program from IDLE, PyCharm, or other IDE you might be using.
4. Gain familiarity with how the HumansRobotsFerry.py formulation works.

(a) Run the interactive solving client and by trying different operators solve the problem of getting all the humans and robots across the river. (b) Examine the formulation code, and focus most of your attention on the can_move method, which implements the preconditions for all the operators of this formulation. (c) In this method, there are five lines of code containing "return False". Explain what is going on in the 4th one of these lines. Put your answer into your report file ("A1Report.pdf") under the heading "Step 4 (c)." To create your A1Report.pdf, you should rename the starter-code file, which has the name "A1_Report_Template.tex" to "A1Report.tex" and then edit that in Overleaf. If you are not inclined to use Overleaf, you may create a comparable file in Word or Google Docs and then convert it to pdf. You can see the "empty" PDF version of the template here.

5. Create your own problem formulation for the "Farmer, Fox, Chicken, and Grain" problem covered in class. Your code should follow the same structure used in HumansRobotsFerry.py. For your operators, implement the set of operators given in the solution to the worksheet (posted in ED) on the Farmer, Fox, Chicken and Grain problem. Define the operators in the same order that they appear in the presentation of the set of operators in the given solution. That will help ensure that solutions found by algorithms will match the expected solutions. Test your formulation using the Interactive solving client and debug your formulation as needed.
6. Then produce a session transcript for your formulation based on an automated solver. This transcript will be in the form of a log file. You can produce it by running the starter-code program DFS.py and capturing the output and directing it to a file. The file should be named FFCG-log.txt.
7. Using parts of the starter-code file DFS.py, which implements a loop-based depth-first search method ("DFS" in the following), implement BFS (Breadth-First Search) as it is specified in the lecture slides. Put your implementation of BFS into the starter-template file BFS.py. Make sure that these implementations keep track of "predecessor" links (also known as back links), and they can report a shortest path from start to goal, for whatever problem they are applied to. (You can implement these links using a hash table, i.e., dictionary, that maps each state other than the initial state to its parent state. The initial state should be mapped to a special value such as None, or -1, which is up to you.)
8. Compare DFS and BFS on the following problems: (i) Humans, Robots and Ferry, (ii) Farmer, Fox, Chicken, and Grain, and (iii) 4-Disk Towers of Hanoi. For each combination of algorithm and problem, report the following: (a) the path found from start to goal, (b) the length of the path, (c) the number of nodes expanded (i.e., removed from OPEN and had successors generated even if there were 0 successors), and (d) the maximum length of the OPEN list. (DFS prints this; have your BFS print it too.) Report this information by entering it into your report document using the table provided in its template file. The boxes marked "skip" are not required; however, the PATH LENGTHS, NODES EXPANDED, and MAX OPEN cells in the same rows DO require entries for full credit. (e) Finally, just for the Towers-of-Hanoi problem with 4 disks, explain (i) why the maximum length of the OPEN list is more for one algorithm than the other, and (ii) why the solution PATH length is different for one algorithm from that of the other. Include the table in your report, under the section heading "Step 8".
Written Report

9. Report file. Put your reporting items from Steps 4(c) and 8 into your report file A1Report.pdf, following the structure of the template A1_Report_Template.tex that comes with the starter code. Also fill in the template's general sections (Goals, Activities, Challenges & Solutions, Reflections/Learnings, and Next Steps), which are described on the Assignment Reports page. If you prefer to use Word, please use the same report style and structure.
10. AI Use. In the AI Use section of the template, list the models and tools you used, and give your prompt log, as described on the Assignment Reports page: the full prompting conversation if it is not longer than 50K bytes, or otherwise just your own prompts.
11. Partnership retrospective. At the end of your report, include your "partnership retrospective." This starts with whether or not you worked in a partnership. Then, if so, it will contain (a) the names of the people in your team, (b) how you divided up the work, and (c) what if anything in this collaboration was a new experience for either partner.
Keep in Mind

Here are some ideas to keep in mind for this assignment. The problem format we are using not only permits the "manual solving" that you do with the Interactive Solving Client. It also permits automatic solving, such as with DFS, and BFS. Thus it is important that you follow the problem structure correctly. Certain methods are required in the State class, including __init__, __eq__, __hash__, __str__, and copy. The operators must have the correct structure, as well. The nice thing about the Interactive Solving Client is that it provides a pretty good means to test whether your formulation will be OK. You will also be reusing this formulation framework and your search code in Assignment 2.

Even if you are familiar with Python, there may be some constructs in the formulation files that you are not familiar with. You can read up on list comprehensions (p.31 of the first reading) and lambda expressions (pp. 47-52 of that reading).

Parts of your code will be graded by an autograder. To do this, your files will be imported as modules by the autograder. Your search should not automatically start running when the module is imported. The starter-code search files come with some code at the end of the file that takes care of this. This code is: "if __name__ == '__main__' " which avoids running the search automatically if it is being imported, but still runs it automatically if it is the main program. The autograder will be comparing the solutions and statistics found by your code with expected solutions, by calling functions in your code and examining the values of certain variables in your code. These variables are generally already in place for you in the starter code. So you should not rename variables like self.PATH or any of the other variables written with all CAPITAL letters.

Commenting your Code

Each of your Python files should begin with a multiline string (more details are shown below.)

Follow reasonable commenting practice in your code. The comments in the starter code can serve as examples of the commenting style that we consider appropriate.

What to Turn In

Turn in the following files to Gradescope:

Farmer_Fox.py
FFCG-log.txt
BFS.py
A1Report.pdf
Each of the Python files should start with a multiline comment in the following format with your own information rather than the sample information given here.
'''Farmer_Fox.py
by John Nathan Smith and Emily Doe
UWNetIDs: jnsmith25, emilydoe24
Student numbers: 2576543, 2483119

Assignment 1, in CSE 415, Autumn 2026

This file contains my (or our) problem formulation for the problem of
the Farmer, Fox, Chicken, and Grain.
'''

Your file "A1Report.pdf" will start with some specific information given in the template. Then it will contain your results for Steps 4(c) and 8, then the general sections (including AI use and your prompt log), and at the end, your partnership retrospective.

The turn-in method is via file uploads to Gradescope. Be sure to upload your files to the A1 assignment.

Updates and Corrections
 
If needed, updates and corrections will be posted here, and/or in ED.
Last updated 2026-09-24.