Implementing Algorithms - Thinking Like Computers - Lecture Slides, Slides of Artificial Intelligence

During the course work of Thinking Like Computers, we study the key concept of artificial intelligence. The main points in these lecture slides are given as:Implementing Algorithms, Javascript Programming, Combination of Random, Decision Games, Multiplayer Decisions, Game Theory, Nash Equilibrium, Prisoner’ Dilemma, Utility of Strategies, Zero-Sum Games

Typology: Slides

2012/2013

Uploaded on 04/24/2013

banani
banani 🇮🇳

4.3

(3)

91 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CSCI 100
Think Like Computers
Lecture 24
Fall 2008
Last Time …
Implementing algorithms
Binary search
Sorting
Homework 4 – Due December 12
Javascript programming: simulation!
We are going to run simulations for the
Prisoner’s Dilemma problem:
Two men are collectively char ged with a crime and
held in separate cells.
They can’t communicate with each other.
They are told:
(1) if one of them confesses to the crime and the other does
not, the confessor will be freed, and the other jailed for 5
years
(2) if both confess, each will be jailed for 2 years
(3) if neither confesses, they will each be jailed for 1 year
Homework 4
Write a program to play the iterated
version:
Each round is the Prisoner’s Dilemma: the
program chooses C or D
At each round, the program has previous
choices (both players) stored, and can use
that information to choose C or D
Play 200 rounds
Homework 4
You are going to play against other
“programs” (you’ll simulate them as well):
All-D: Always choose D.
Random: choose C or D randomly.
Tit-for-Tat: first round, choose C; later, at
round t, do what your opponent did on round
t-1.
Now check your program’s score (total
years) against them and print out.
Homework 4
Hints: you can be as creative as you can –
but you do want to score the best. You
may try:
Some variation of the Tit-for-tat
Combination of random and Tit-for-tat
Switch/repeat strategies from time to time
But don’t try overly complicated methods!
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Implementing Algorithms - Thinking Like Computers - Lecture Slides and more Slides Artificial Intelligence in PDF only on Docsity!

CSCI 100

Think Like Computers

Lecture 24

Fall 2008

Last Time …

  • Implementing algorithms
  • Binary search
  • Sorting

Homework 4 – Due December 12

  • Javascript programming: simulation!
  • We are going to run simulations for the Prisoner’s Dilemma problem: Š Two men are collectively charged with a crime and held in separate cells. Š They can’t communicate with each other. Š They are told: ƒ (1) if one of them confesses to the crime and the other does not, the confessor will be freed, and the other jailed for 5 years ƒ (2) if both confess, each will be jailed for 2 years ƒ (3) if neither confesses, they will each be jailed for 1 year

Homework 4

  • Write a program to play the iterated

version:

Š Each round is the Prisoner’s Dilemma: the program chooses C or D Š At each round, the program has previous choices (both players) stored, and can use that information to choose C or D Š Play 200 rounds

Homework 4

  • You are going to play against other

“programs” (you’ll simulate them as well):

Š All-D: Always choose D. Š Random: choose C or D randomly. Š Tit-for-Tat: first round, choose C; later, at round t, do what your opponent did on round t-1.

  • Now check your program’s score (total

years) against them and print out.

Homework 4

  • Hints: you can be as creative as you can –

but you do want to score the best. You

may try:

Š Some variation of the Tit-for-tat Š Combination of random and Tit-for-tat Š Switch/repeat strategies from time to time

  • But don’t try overly complicated methods!

Decision Games

  • Going back to the topic of how computer

thinks:

Š Preferences Š Utilities Š Decisions (Rationality) Š Learning

  • So we can make decisions (in theory) to

deal with uncertainty

Multiplayer decisions

  • What if there are other players in the

system?

  • Well, you decision will affect their

decisions, and vice versa…

  • Now you also need to take into

considerations of other decision makers

Game Theory

  • These problems are studied in Game

Theory.

  • Fairly complicated
  • Very mathematical
  • But also very practical

Nash Equilibrium

  • John Nash (the movie A Beautiful Mind)
  • Game payoff matrix (for 2 players) Š Prisoner’s Dilemma

1 years 1 years

0 years 5 years

A cooperates

5 years 0 years

2 years 2 years

A defects

B defects B cooperates

The Prisoner’ Dilemma

What should A (or B) do?

3 3

5 0

A cooperates

0 5

2 2

A defects

B defects B cooperates

The Utility (not the same as years in prison)

Strategies

  • There are several strategies: Š D (defects) Š C (cooperates) Š Random ƒ Can be viewed as a mixture of the previous 2 strategies (like a lottery)
  • Can we talk about the utility of strategies?

Prisoner’s Dilemma

  • Enough abstract theory. Let’s apply to

some actual scenarios: first, the prisoner’s

dilemma:

Š As described earlier …

  • It’s actually fairly common Š Nuclear weapons treaty ƒ Cooperate: get rid of weapons ƒ But … what if you get the sucker’s payoff?

How to Interpret

The Prisoner’s Dilemma

  • The rational thing is defect (not cooperate) Š A bit upsetting
  • It seems to imply that cooperation can only

arise as a result of irrational behavior, and

  • cooperative behavior can be exploited by

those who behave rationally

Š The natural is “red in tooth and claw”?

Efforts to “recover” cooperation

    1. We are not all Machiavelli – some

altruism

Š Given up your seat on the bus to … Š Altruism? Or being afraid of punishments?

Š Consider a public transport system relying on every one honestly paying (not verified)

Recover Cooperation

  • The other prisoner is my twin! Š “Think alike” ƒ Cooperation is the best outcome. Š What if everyone were to behave like that … ƒ Joseph Heller’s Catch 22 ƒ You’d be a fool to behave any other way

Recover Cooperation

  • People are not rational … Š We’d risk cooperation when the sucker’s payoff really does not matter very much Š Paying a bus fare of a few pennies does not hurt much, even if everybody else is defecting

Recover Cooperation

  • The shadow of the future Š What if we play the game more than once? Š Iterated game: many rounds Š In fact, infinite rounds
  • If you defect, your opponent can punish

you by also defecting (not possible in one-

round game)

  • If you test the water by cooperating? Š Cooperation becomes rational

Axelrod’s Tournament

  • For iterated Prisoner’s dilemma:

Š 1980 Š Many strategies were submitted

  • Examples:

Š All-D Š Random Š Tit-for-Tat (the overall winner, only 5 lines) Š …

Tit-for-Tat

  • Tit-for-tat is not the optimal strategy
  • It was able to succeed because it had the

opportunity to play against other programs

that were also inclined to cooperate.

Tit-for-Tat

  • Reasons for its success:

Š Do not be envious. Š Do not be the first to defect. Š Reciprocate cooperation and defection. Š Do not be too clever!