computer simulation (2) game playing. different types of games how many players? –one –two...

23
Computer Simulation (2) Game Playing

Post on 19-Dec-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Computer Simulation (2)Game Playing

Page 2: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Different Types of Games

• How many players?– One– Two

• Element of chance?– Deterministic– Nondeterministic

• Outcome– Zero sum (what one player wins, the other loses)– Non-zero sum

Page 3: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Different types of Games

Tower of Hanoi Solitaire

Chess

Tic-Tac-Toe

Go

Backgammon

Poker

Deterministic Nondeterministic

One Player

TwoPlayer

Page 4: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Using hill climbing for one player games

17 38 49 30 68 7 4 18

17 20 8 9

15 7

12

5

18 11 9 25 7 10 32 28

13 6 6 15

12 18

11

Start

(higher = better)

Page 5: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Game Tree for two person game

My Turn

Your Turn

My Turn

Your Turn

Page 6: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Game TreeMy

Turn = ??

Your Turn

My Turn

Your Turn

+1 +1 +1 +1 +1 +1 +1 +1 -1 +1 -1 +1 +1 -1 +1 -1

a1 a2

+1 = I win -1 = you win

Page 7: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Perfect decisions with two player games

• Each player will make the best decisions possible:

Player A: maximize score (higher scores better for A)

Player B: minimize score (lower scores better for B)

7 6 5 68

A

B

a1 a2

b1 b2 b3 b4

Page 8: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

The Minimax Procedure

8 13 11 25 21 5 17 19

A

B

A

B

a1 a2

b1b2 b3

b4

a1 a2 a3 a4 a5 a6 a7 a8

1) Work upwards, 2) B will always pick minimum, and 3) A will always pick maximum

Page 9: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

What does Minimax predict A will do?

17 38 49 30 68 7 4 18 18 11 9 25 7 10 32 28

A

B

A

B

a1 a2

b1b2 b3

b4

Page 10: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Fighting Combinatorial Explosion

limit branching factor

pruning the search tree

Page 11: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Depth-First Search

A

B

Page 12: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Depth-First Search & Minimax

7

A

9 8 7

4

6 5 4

1

3 2 1

7

B

Page 13: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Alpha-Beta Pruning

7

A

9 8 7

6

6 ? ?

?

? ? ?

7

B

AT LEAST 7

AT MOST 6no need to visit other branchesbelow this node

Page 14: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Alpha-Beta Pruning

7

A

9 8 7

6

6 ? ?

3

3 ? ?

7

B

Some states do not need to be searched!The alpha-beta method cleverly eliminates large part of the search space

Page 15: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Perfect Play with Connect 4

• Play the game against the computer– http://www.farfarfar.com/games/connect_four/– http://www.pomakis.com/c4/

• Perfect play – the game of Connect 4 can be planned to the end

• the first player can force a win by starting in the middle column. Starting in the two adjacent columns allows the second player to reach a draw; starting with the border columns even allows the second player to force a win.

• Why play the game if the outcome is already known (assuming perfect play)?

(content copied from http://encyclopedia.thefreedictionary.com/Connect%20Four)

Page 16: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Complexity of Game Trees

• Most games cannot be planned to the end -> combinatorial explosion

• Number of states to search = (N)D

– Branching factor (N):number of legal moves at each position (on average)

– Depth (D) = number of moves till the end

Page 17: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Branching factor

• Chess:

Branching factor = about 35 moves/ positions

Depth = about 100 moves total

(35)100 ≈ (10)120 number of positions to search

• Intelligent Search: decrease the branching factor

(35)2=1225 (35)6=1,838,265,625 vs.:

(5)2=25 (5)6=15,625

Page 18: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Chess Computers

• 1997: IBM’s Deep blue played world champion Gary Kasparov

Deep blue: 250,000,000 positions/sec

Kasparov: ?? positions/sec

• Brute force vs. Intelligent search

Page 19: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Comparing Brains & Computers

BRAINS COMPUTERS

Neurons/organicParallel computationDistributed MemoryUnreliable partsResistant to damageNot understood

Conscious/Intelligent

Silicon/ MetallicSerial ComputationLocalized MemoryReliable partsVulnerableUnderstood

??

Page 20: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Ask Yourself

Do you consider your own mind to be a bunch of software programs? Probably not!

Turing's challenge was this:

Can you really say what the difference is between the mind of a human being and the artificial 'mind' of a computer which simulates a human mind?

Page 21: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Turing Test

1.Interrogator2.Human3.Computer Program

Interrogator tries to determine who is the human and who is theComputer program

Page 22: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Loebner Prize

JUDGE: Is it April or May?ENTRANT: Um. I believe it's April.JUDGE: Why do you say that?ENTRANT: That's a very good question. Because months and days and so on are arbitrary - I suppose.JUDGE: It seems you are taking a certain tone with me. An agitated, human tone.ENTRANT: Really? You are somewhat reticent yourself.JUDGE: I never said you were reticent.ENTRANT: I know.JUDGE: Smug.ENTRANT: Moi*?JUDGE: I think you might be human.

Page 23: Computer Simulation (2) Game Playing. Different Types of Games How many players? –One –Two Element of chance? –Deterministic –Nondeterministic Outcome

Some clever programs

– Computer therapist ELIZA: • http://www-ai.ijs.si/eliza/eliza.html• http://www.manifestation.com/neurotoys/eliza.php3

– Modern chatter boxes:• http://cogsci.ucsd.edu/~asaygin/tt/ttest.html• http://www.abenteuermedien.de/jabberwock/• http://www.turinghub.com/turinghub.html

– Computer programs that learn: 20 Questions• http://y.20q.net:8095/btest