# Lab 3: A simple reflex agent loses its way — step-by-step guide

## Context

This laboratory accompanies Lecture 1 (slides 32–35) of 5DV248 Trustworthy Human-AI Interaction and follows AIMA Sections 2.3–2.4.2. Lab 2 showed that rationality depends on the performance measure. This lab demonstrates the first limitation announced on slide 35: simple reflex agents select actions on the basis of the current percept alone, they have no memory, and therefore they work only if the environment is fully observable. The world is a corridor of four squares; the agent sees only the square it currently occupies. Everything else is fog.

## Objective

The objective is to make the warning on slide 35 observable rather than merely stated: "a little bit of unobservability can cause serious trouble". Concretely, you will see three things:

1. With the location sensor on, the condition-action rules drive the agent successfully along the corridor.
2. With the location sensor off, the percept becomes (?, status). No rule in the agent function matches an unknown location, so the agent stops doing anything useful — without any error message, without any failure signal.
3. With a flaky suction motor, the world also becomes stochastic: the same action no longer guarantees the same result.

## The interface

- The grid shows the true world, which you can see but the agent cannot. Dark cells are fog: outside the agent's perception. Brown cells are dirty.
- The blue dot is the agent. When the location sensor is on, the dot is solid: the agent knows where it is. When the sensor is off, the dot becomes dashed: the agent still occupies that square, but it no longer knows which square it is in.
- The checkboxes configure the environment along the dimensions from the lecture:
  - Location sensor on: fully versus partially observable;
  - Flaky Suck motor: deterministic versus stochastic (suction succeeds only 80% of the time);
  - Dirt sensor works at every cell: whether the status part of the percept is reliable.
- Step executes one percept-action cycle; Run repeats them automatically; Reset returns the agent to the first square; New dirt generates a random new dirt configuration.
- The percept box shows, at every step, exactly the pair the agent receives: (location, status). When the sensor is off, the location reads "?". This box is the entire input to the agent function.
- The decision log records each percept and the action chosen; the counters report time steps, moves, Suck actions and the squares still dirty.

## Your goal as a student

You are the analyst: the agent function is fixed (shown on the right of the page), and your task is to explain its failures. Proceed as follows and write down your predictions before each change:

1. With all sensors on, press Run and describe the agent's behaviour in your own words: which rule fires at each square, and why does the corridor eventually become clean?
2. Predict what the agent will do when it reaches the rightmost square and that square is clean. Verify with the log. Why does the agent keep moving at all?
3. Now switch the location sensor off and press Run. Explain, by tracing the percept (?, Dirty) and (?, Clean) through the if–then rules of the agent function, why the agent freezes. Which branch of the rules matches an unknown location?
4. Switch the flaky motor on as well. Observe in the log the "Suck (FAILED - motor)" entries. The agent cannot distinguish a failed Suck from a successful one: why not, and what would the agent need in order to notice?
5. Classify this environment along the AIMA taxonomy from the lecture (observable, single- versus multi-agent, deterministic, episodic versus sequential, static, discrete, known), once with all sensors on and once with the location sensor off and the flaky motor on. Write your two classifications down; the difference is the whole point of the lab.
6. Conclude with the bridge to Lab 4: the slides promise that internal state fixes partial observability. Name the single piece of remembered information that would repair this agent in the fog, and bring your answer to Lab 4, where you will implement exactly that.

## What to submit or discuss

A short reflection (half a page) containing: your predicted versus observed behaviour in steps 2 and 3, the two environment classifications from step 5, and your proposed piece of internal state from step 6. In the discussion, connect your answer to slide 35: which of the two listed cons of simple reflex agents did you observe, and what exactly would memory change?