Revision 4dd0a6ae0c10cb92196d7126903bd24d0d085025 (click the page title to view the current version)

Rational Agents

Changes from 4dd0a6ae0c10cb92196d7126903bd24d0d085025 to 8cc6b9fecc9797e480f2b2a338221e014a8fc812

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

# 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

## Module evaluation

+ Status report.
+ Questions and Answers?

## Recap from last week

We discuss the content from R&N Ch. 1.

**TODO** review

+ 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

We divide the class into four groups for each of the talking points.
You can use OneNote to enter some notes from your brainstorming.
Finally, each group present briefly their topic before a short discussion and comments from the class and teacher.

## Lecture

See [Lecture on Rational Agents]()

## Discussion 

We discuss the content presented by R&N Ch. 2.

+ definition of agent 
+ percept and percept sequence
+ agent function and agent program
+ rational agents and performance measures
+ omniscience, learning, and autonomy
+ task environments and PEAS
+ properties of task environments
+ table-driven agents
+ simple reflex agents
+ model-based reflex agents
+ goal-based agents
+ utility-based agents
+ learning agents

Working in pairs, each student in a pair will get 10 mins to prepare a talking point from the list, before giving a short oral presentation to the other student, and vice versa. 
This is called *peer-tutoring*.
Afterwards, we will discuss the exercise and clarify certain topics and questions you might have (if any).

## 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.
After having worked on the problem for a little, with notetaking in OneNote, the worked solutions will be presented to the rest of the class.


# Exercises

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. 

## 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

## Challenges

In CodinGame, the following challenges may be useful:
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.

### Intelligent Agents

+ [Shadows of the Knight Episode 1](https://www.codingame.com/training/medium/shadows-of-the-knight-episode-1) (medium): intervals, binary search
The following challenges have a percept-compute-act loop, and
thus fits into the framework of intelligent actions.
For each challenge you solve, you should discuss how it
the problem and your solution can be classified using 
the terminology of R&N Ch. 2.  

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
+ [Bender Episode 4](https://www.codingame.com/multiplayer/optimization/bender---episode-4)
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. [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

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

# Homework

Prepare yourself for the next workshop by doing the following:

1.  Review the reading material for this class.
2.  Do the preparation for the next lecture, on [Search]().