729G78 Artificiell intelligens
Laboration 2: Sökagenter
Purpose
The purpose of this lab is to understand how to develop agents that can plan their actions using search strategies. The environment is similar to the previous lab but additionally contains randomly positioned walls.
Description
In this lab, the environment is fully observable. This means that the agent has complete knowledge of the world (e.g. where food is and where walls are) and can thus plan its path through the room before performing any actions. The lab is divided into two parts:
- Keep track of the agent's position, direction, the coordinates that contain food, and which actions the agent has performed to reach the current state, by defining its internal state.
- Write a search algorithm to generate a plan allowing the hungry agent to devour all the food in the room.
Preparation
Read chapter 3 on search algorithms in Artificial Intelligence: A Modern Approach. A basic understanding of the principles underlying the classical search algorithms will be assumed throughout this lab.
Getting started
- Create a directory for this lab and navigate into from a terminal
- Copy the lab files from the course directory:
~/Lab2$ cp -r /courses/729G78/Lab2/* . - Activate the lab environment. The environment needs to be activated again if the terminal is closed.
~/Lab2$ source /courses/729G78/labs/env/bin/activate - Run the notebook:
~/Lab2$ jupyter notebook Lab2_LiU-ID-1_LiU-ID-2.ipynb
Working on your own computer
- Unix
- Create environment
$ python3 -m venv /path/to/my/lab/environment - Activate the environment
$ source /path/to/my/lab/environment/bin/activate - Confirm that the environment is active (should point to your environment)
$ which python - Install libs using pip
$ pip install notebook pygame
- Create environment
- Windows Power Shell
- Create environment
$ python -m venv /path/to/my/lab/environment - Activate the environment
$ /path/to/my/lab/environment/Scripts/Activate.ps1
On Windows it may be neccessary to fix a problem with execution policy settings:
$ Set-ExecutionPolicy Unrestricted -Scope Process - Confirm that the environment is active (should point to your environment)
$ pip -V - Install libs using pip
$ pip install notebook pygame
- Create environment
- Download and unzip the lab files: Lab2.zip
- Navigate into the unzipped directory and run the notebook using:
$ python3 -m notebook Lab2_LiU-ID-1_LiU-ID-2.ipynb
(Windows Power Shell)
$ python -m notebook Lab2_LiU-ID-1_LiU-ID-2.ipynb - Note: The environment will need to be activated again every time you close the terminal.
Hand-in
-
Complete the exercises in the Jupyter Notebook.
Your agent must be able to operate in environments of arbitrary size.
Test your implementation on different layouts in the
layoutdirectory. - Provide well-motivated discussions. Your answers to the discussion questions must be relevant to the exercises, clearly connected to the course literature, and supported by appropriate reasoning.
- Before submission: Verify that your code works correctly across different layouts. Discuss with your lab partner what information your agent tracks about the environment, why this information is necessary, and how it's maintained and updated.
- Lab review: Review your work with a lab assistant. The assistant will ask questions about your implementation and written report, so make sure that both lab partners understand the code, design decisions, and underlying concepts. For example, how does your loop detection mechanism work?
-
Submit your work: Upload the modified Jupyter
Notebook (
.ipynbfile) and the search tree image to Lisam.
Sidansvarig: Robin Keskisärkkä
