# Lab 2: Rationality depends on the performance measure — step-by-step guide

## Context

This laboratory accompanies Lecture 1 (slides 25–30) of 5DV248 Trustworthy Human-AI Interaction and follows AIMA Sections 2.2–2.3. Lab 1 established that an agent is a function from percepts to actions. This lab adds the second half of the definition of a rational agent: an action is rational only with respect to a **performance measure**, and the performance measure is chosen by the designer. The page runs four simple reflex agents in the same two-square vacuum world, over one hundred randomised runs each, and lets you change the performance measure that decides which agent wins.

## Objective

The objective is to understand, by direct experimentation, three ideas from the lecture:

1. A performance measure evaluates sequences of environment states, not the agent's internal reasoning. Here it is built from numbers you control: a reward per clean square at the end, penalties for each move and each Suck action, a penalty for every dirty square at every time step, and a probability that dirt reappears.
2. Rationality is relative: the same fixed agent can be the best or the worst depending on the measure. No agent is rational in the abstract.
3. The slides advise designing measures around "what one actually wants to be achieved in the environment, rather than how one thinks the agent should behave". The sliders are exactly that choice, made explicit.

## The interface

- The sliders on the left define the performance measure. Each one is a design decision: reward for cleanliness, energy cost of moving, energy cost of suction, hygiene cost of leaving dirt over time, and how dynamic the environment is (dirt that respawns).
- The four agents are fixed simple reflex programs; you cannot change them in this lab, you only judge them:
  - reflex: Suck if dirty, otherwise cross to the other square (the REFLEX-VACUUM-AGENT from the slides);
  - paranoid: keeps moving even when everything is clean;
  - lazy: Suck if dirty, otherwise do nothing (it never moves);
  - random: a uniform random action at every step.
- The Evaluate button runs one hundred runs of twenty steps per agent and averages their scores under the current measure.
- The bar chart shows the average performance of each agent; the winner line names the best agent under the measure you have configured. Bars may point up (positive score) or down (negative score) from the zero line.

## Your goal as a student

You play the designer who fixes the performance measure. Work through the following steps and write down your predictions before each evaluation:

1. With the default settings, predict the ranking of the four agents. Press Evaluate and compare. Explain in one sentence why the lazy agent scores poorly under a measure that rewards final cleanliness.
2. Find a measure under which the lazy agent wins: raise the penalty per move until crossing the room is not worth the cleaning. Verify your prediction and record the slider values that achieve it.
3. Now raise the penalty per dirty cell per time step. This models the hospital floor of the lecture (a hygiene risk at every moment, not only at the end). Which agent benefits? Why does the reflex agent's constant movement pay off here?
4. Compare the reflex and paranoid agents across several measures. Their bars are always identical: explain why, by comparing their condition-action rules. What does this tell you about judging agents by their descriptions rather than by their agent functions?
5. Raise the respawn probability towards 0.3, making the environment more dynamic. Which property from the environment taxonomy (slides 25–30) changes, and which agent suffers the most?
6. Conclude with the central question: is there one measure under which all four agents are equally good? Argue from the definition of a rational agent, and connect your answer to the GAMA firefighter practical: whose performance measure decides whether a firefighter agent is doing a good job?