Göm menyn

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:

  1. 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.
  2. Write a search algorithm to generate a plan allowing the hungry agent to devour all the food in the room.

Preparation

  1. 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

  1. Create a directory for this lab and navigate into from a terminal
  2. Copy the lab files from the course directory:
    ~/Lab2$ cp -r /courses/729G78/Lab2/* .
  3. Rename Lab2_LiU-ID-1_LiU-ID-2.ipynb to match your group's LiU IDs
  4. Rename and open the exercises document Lab2Exercises_LiU-ID-1_LiU-ID-2.odt to match your group's LiU-IDs.
  5. Activate the lab environment. The environment needs to be activated again if the terminal is closed.
    ~/Lab2$ source /courses/729G78/labs/environment/bin/activate
  6. Run the notebook:
    ~/Lab2$ jupyter notebook Lab2_LiU-ID-1_LiU-ID-2.ipynb

Working on your own computer

  • Unix
    1. Create environment
      $ python3 -m venv /path/to/my/lab/environment
    2. Activate the environment
      $ source /path/to/my/lab/environment/bin/activate
    3. Confirm that the environment is active (should point to your environment)
      $ which python
    4. Install libs using pip
      $ pip install notebook pygame
  • Windows Power Shell
    1. Create environment
      $ python -m venv /path/to/my/lab/environment
    2. 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
    3. Confirm that the environment is active (should point to your environment)
      $ pip -V
    4. Install libs using pip
      $ pip install notebook pygame
  • 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

  1. Complete the exercises listed in the Jupyter Notebook.
  2. The discussion in the exercises must be relevant, relate to the course literature, and be sufficiently motivated.
  3. Before handing in: Check that your agent can complete a layout with moderate difficulty. Try to describe to your lab partner the loop detection is implemented.
  4. Upload your modified notebook (the .ipynb-file) and the exercises document (as PDF) in Lisam.


Sidansvarig: Robin Keskisärkkä