Revision 08b725ddf663bfec7a48d520be2e78d7e60ca7be (click the page title to view the current version)

Rational Agents

Changes from 08b725ddf663bfec7a48d520be2e78d7e60ca7be to f34ffd1d69a325dc37d44051e6fcdf578b765c5c

---
title: Rational Agents
categories: session
---

[Overview]() -> Rational Agents

# Preparation

*Reading* Russel & Norvig Chapter (1-)2

# Learning outcomes

After the completion of this workshop, students should

+ be familiar with CodinGame and have successfully solved some of the recommended Medium puzzles.
+ be able to analyse problems with respect to PEAS (performance measure, environment, actuator, sensor).
+ understand and be able to explain what kind of agent they have implemented (e.g., reflex agent, planning agent, etc.) and whether their agents (or more generally, solution methods) are rational.
+ be familiar on an introductory level with basic data structures and algorithms (e.g., lists, sets, trees, binary search, greedy search).
+ be able to understand and answer the sample exam questions posted on Blackboard that relate to the material covered in this workshop.

# Briefing

## Recap from last week

We discuss the content from R&N Ch. 1 and the material studied
last week.  Two questions, state the most important point only:

1.  What have you learnt so far?
1.  What is your greatest challenge for today?

Keywords from last week

+ four definitions of AI along the axes of thinking and acting
   humanly and rationally.
+ foundations of AI, e.g., philosophy, mathematics, economics, neuroscience, psychology, computer engineering, control theory and cybernetics, linguistics
+ the history of AI
+ applications of AI and state-of-the-art

## Review of the reading assignment

![Agent is the perceive-think-act cycle](agent.png)

We divide the group in three groups, 
to discuss each of the following topics from the 
reading assignments.  Each topic should be discussed
using the coding problems from last week as examples.

1.  PEAS - Performace Measure, Environment, Actuators, Sensors
2.  Properties of the task environment
    + Fully or partially observable
    + Single or multi-agent
    + Deterministic or not
    + Episodic or sequential
    + Static or dynamic
    + Discrete or continuous
    + Known or unknown
2.  Program Type
    + simple reflex agent
    + model-based agents
    + goal-based agents
    + utility-based agents
    + learning agents

There are lecture notes prepared, but not necessarily used.
See [Lecture on Rational Agents]()

# Challenges

We continue solving coding challenges primarily on CodinGame. 
As we progress, try to draw a connection between the coding challenges
and the topics we learn. 
Some help on particular puzzles is provided in the Forum on Blackboard. 

Depending on your background, you may want to use GodinGame
to train basic programming and algorithmic skills, or 
to test the rational agent framework discussed today.
The challenges are split in two section below.

It is assumed that everybody solved the *Power of Thor* last
week.   The solution we discussed in class may prove to be
an important pre-requisite below.  Apart from this one,
the most important problems from last week have been repeated
below.

## Preliminaries

Note that knowledge about various data structures and trees,
in particular, binary search trees, will be useful before
implementing algorithms presented in this course.
You should explore such functionality in your programming language of choice,
e.g., in Java, the 
[Collections Framework](https://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html)
includes various useful interfaces and classes, e.g.

+ Set: HashSet, TreeSet, LinkedHashSet
+ List: ArrayList, LinkedList
+ Deque: ArrayDeque, LinkedList
+ Map: HashMap, TreeMap, LinkedHashMap

**Note**
I do not want to use a lot of time to discuss these preliminaries,
because for some of you, it is undergraduate material.  However,
I am happy to discuss problems with those of you who need it.
If these data structures are new to you, you should spend some
time on the algorithmic problems below, and ask for help.

## Intelligent Agents

These challenges fit fairly well into the
framework of intelligent actions.
Three rules to keep in mind.

1. For each challenge you solve, discuss how it
   the problem and your solution can be classified using 
   the terminology of R&N Ch. 2.  
2. Remember that you make **autonomous** robots.
    + An important part of the problem is to imagine what the robot will
      know at any given point in the program, and reason how to act in the
      given situation.
3.  Use **pair programming**.
    + This is a well tested and proven technique for programming and problem
      solving.
    + If you think you prefer to work alone, you still have to **try** pair
      programming this once, and then you can tell me afterwards.  Thus,
      *team up in pairs* and choose a problem to attack.

### Suggested problems

1. [The Descent](https://www.codingame.com/ide/puzzle/the-descent)
    + *This was also given in Week 1.*
    + Description: The enterprise is in danger:
      drawn towards the surface of an unknown planet, it is at risk of
      crashing against towering mountains.
      Help Kirk and Spock destroy the mountains... Save the enterprise!
    + Topic: Search in an array
1. [Shadows of the Knight Episode 1](https://www.codingame.com/training/medium/shadows-of-the-knight-episode-1) (medium): intervals, binary search
    + Intelligent Agent
    + Some similarities with the Þor problem last week, but this time the target location is not precisely known
1. [Mars Lander --- Episode 1](https://www.codingame.com/ide/puzzle/mars-lander-episode-1)
    + *This was also given in Week 1.*
    + Description:
      You have been promoted to commander of the Mars Lander mission!
      The goal of the operation is to land an exploration rover on
      martian ground.
      Your superiors at NASA expect very much of you for this mission,
      and you'll have to prove that you have what it takes to become a
      great intersideral commander.
      You will have to land the space ship on mars,
      making sure that the landing is done smoothly.
    + Topic: Speed regulation
3. [The Fall E1](https://www.codingame.com/ide/puzzle/the-last-crusade-episode-1)
    + Here you have to predict a robot's movement, rather than direct it.
3. [Blunder Episode 1](https://www.codingame.com/training/hard/blunder-episode-1)
    + Description:
      Bender is a depressed robot who heals his depression by partying and drinking alcohol.
    + To save him from a life of debauchery, his creators have reprogrammed the control system with a more rudimentary intelligence.
    + Unfortunately, he has lost his sense of humor and his former friends have now rejected him.
    + Bender is now all alone and is wandering through the streets of Futurama with the intention of ending it all in a suicide booth.
    + To intercept him and save him from almost certain death, the authorities have given you a mission: write a program that will make it possible to foresee the path that Bender follows. To do so, you are given the logic for the new intelligence with which Bender has been programmed as well as a map of the city.
3. [Bender Episode 4](https://www.codingame.com/multiplayer/optimization/bender---episode-4)
    + This is a challenge.  You have to take care to build the model
      and the search tree.
    + Note that you have to find the entire path in your model, and then
      execute your program.  You cannot use a perception loop to try and err.
    + Work in **groups**.  Discuss the model and make sure you can agree on
      an understanding.
    + Previous episodes no longer available


Feel free to look for additional challenges to solve.

### Algorithmic Challenges

The following challenges are more basic algorithmic problems,
which may be usefual to practice programming and problem solving
in general.  You may las

+ [There is no Spoon](https://www.codingame.com/training/medium/there-is-no-spoon-episode-1) (medium): lists
    - Search problem 
    - Using lists is not the only solution
+ [Telephone Numbers](https://www.codingame.com/training/medium/telephone-numbers) (medium): trees, sets
    - Calculation - modelling challenge 
    - many solutions - can be simulated
+ [Advanced tree](https://www.codingame.com/training/medium/advanced-tree) (medium): tree
    - Build and print a tree
+ [The Gift](https://www.codingame.com/training/medium/the-gift) (medium): greedy algorithms
    + Mathematical problem

# Lunch-time Heads Up

We review the experiences made in CodinGame.

# Debrief

## Module evaluation

+ Status report.
+ Questions and Answers?

## End-of-chapter exercises in AIMA Ch. 2

Working individually or in pairs, students will be assigned an exercise
from the end-of-chapter exercises in AIMA Ch. 2.


# Homework

Prepare yourself for the next workshop by doing the following:

1.  Review what you have learnt this session.
2.  Do the preparation for the next lecture, on [Search]().