Programming a Computer for Playing Chess By Claude E. Shannon.

Slides:



Advertisements
Similar presentations
Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Advertisements

Adversarial Search Reference: “Artificial Intelligence: A Modern Approach, 3 rd ed” (Russell and Norvig)
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
Games & Adversarial Search
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
Adversarial Search Chapter 5.
L.O. Today you will learn how to play chess. How to Play Chess.
"Programming a Computer to Play Chess" A presentation of C. Shannon's 1950 paper by Andrew Oldag April
Adversarial Search CSE 473 University of Washington.
Hoe schaakt een computer? Arnold Meijster. Why study games? Fun Historically major subject in AI Interesting subject of study because they are hard Games.
Artificial Intelligence for Games Game playing Patrick Olivier
Artificial Intelligence in Game Design Heuristics and Other Ideas in Board Games.
An Introduction to Artificial Intelligence Lecture VI: Adversarial Search (Games) Ramin Halavati In which we examine problems.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
10/19/2004TCSS435A Isabelle Bichindaritz1 Game and Tree Searching.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
Module 3 Chess 101 Strategy Strategy refers to an overall plan to achieve a goal In every game you play your goal should be to checkmate your opponent,
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
This time: Outline Game playing The minimax algorithm
Game Playing CSC361 AI CSC361: Game Playing.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.6: Adversarial Search Fall 2008 Marco Valtorta.
Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
Group 1 : Ashutosh Pushkar Ameya Sudhir From. Motivation  Game playing was one of the first tasks undertaken in AI  Study of games brings us closer.
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
CSC 412: AI Adversarial Search
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
Lecture 5 Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi. Text Book - Aritificial Intelligence Illuminated.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Game Playing.
Artificial Intelligence in Game Design Lecture 22: Heuristics and Other Ideas in Board Games.
Apostles Chess Club Session Three. Chess Piece Symbols The symbols shown above are the ones most used when showing chess pieces in print or on the internet.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Instructor: Vincent Conitzer
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 9 of 42 Wednesday, 14.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
How to Play Chess. Name of Each Piece The relative values of the chess pieces 9 points 5 points 3+ points 3 points 1 point.
Game Playing Revision Mini-Max search Alpha-Beta pruning General concerns on games.
Today’s Topics Playing Deterministic (no Dice, etc) Games –Mini-max –  -  pruning –ML and games? 1997: Computer Chess Player (IBM’s Deep Blue) Beat Human.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
CHESS Club.  The game of chess is over 1300 years old and is one of the most popular games in the world. It has received more total thought time than.
Adversarial Search Chapter 6 Section 1 – 4. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time.
Adversarial Search 2 (Game Playing)
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
Adversarial Search and Game-Playing
PENGANTAR INTELIJENSIA BUATAN (64A614)
CS Fall 2016 (Shavlik©), Lecture 11, Week 6
Chess Merit Badge Chess Problems by Joseph L. Bell © 2011.
Games & Adversarial Search
The Alpha-Beta Procedure
Mini-Max search Alpha-Beta pruning General concerns on games
Based on slides by: Rob Powers Ian Gent
Games & Adversarial Search
Games & Adversarial Search
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Programming a Computer for Playing Chess By Claude E. Shannon

Programming a Computer for Playing Chess Published in “Philosophical Magazine”, in Considered as an important milestone in computer chess programming

About the paper Written while Shannon was working in Bell Telephone Laboratories One of Shannon famous “hobbies” as well as cycling and juggling Surveys the problem of constructing a computer routine for a modern computer that will play chess

First chess “machine”… First machine built in 1769 Constructed by the Hungarian engineer von Kempelen for queen Maria Theresia. Had outstanding playing strength Mechanical device supplied by a human chess master hidden inside. It was a *FAKE*

El Ajedrecista (chess player)- Playing a Rook-King Endgame Invented in 1914 by Leonardo Torres y Quevedo Played rook and king against a king Machine forced checkmate no matter however its opponent played Explicit set of rules - relatively simple idea

Turing’s “paper machine” Was written soon after WWII Instruction that would enable a machine to play chess no machines that could execute the instructions... Turing acts as a human CPU More than ½ hour per move ! However…looses to one of his colleagues

Turing’s “paper machine” Here's the historic game: Turing's paper machine – Alick Glennie, Manchester 1952 : 1.e4 e5 2.Nc3 Nf6 3.d4 Bb4 4.Nf3 d6 5.Bd2 Nc6 6.d5 Nd4 7.h4 Bg4 8.a4 Nxf3+ 9.gxf3 Bh5 10.Bb5+ c6 11.dxc cxb7 Rb8 13.Ba6 Qa5 14.Qe2 Nd7 15.Rg1 Nc5 16.Rg5 Bg6 17.Bb5 Nxb Nc5 19.Bc6 Rfc8 20.Bd5 Bxc3 21.Bxc3 Qxa4 22.Kd2? [22.h5 would have trapped the bishop] 22...Ne6 23.Rg4 Nd4? [23...Rxb2! 24.Bxb2 Rxc2+] 24.Qd3 Nb5 25.Bb3 Qa6 26.Bc4 Bh5 27.Rg3 Qa4 28.Bxb5 Qxb5 29.Qxd6 Rd8 0-1.

First win for a computer MANIAC I was delivered in 1950 for developing atomic weapons Before calculating detonation parameters, was tested with a limited chess program Simplified 6x6 board without bishops Twelve minutes to search up to four ply (2 moves) In Los Alamos, 1956 it wins in 23 moves against a young lady who learnt the game a week before the game. First win of a machine against a human player

Why Chess? Sharply defined problem both in operations (moves) and ultimate goal (checkmate) Neither trivial nor too difficult for satisfactory solution Its discrete structure fits well modern computers *** Chess is generally considered to require “thinking” for a skilful play. A solution to this problem will force us to admit that machine thinks, or further restrict the concept of “thinking” ***

Definition of a “Chess Position” 1.A statement of the positions of all pieces on the board. 2.A statement of which side, White or Black, has the move. 3.A statement as to whether the king and rooks have moved. 4.A statement of, say, the last move. This will determine whether a possible en passant capture is legal 5.A statement of the number of moves made since the last pawn move or capture.

Game Types Games can be deterministic or non-deterministic “probabilistic”, “stochastic” …and have perfect information or not “Accessible” – The world state is fully accessible to the program or agent (nothing hidden)

50-move drawing rule The F.I.D.E. Laws of Chess the game is drawn when a player having the move claims a draw and demonstrates that at least [the last?] 50 consecutive moves have been made by each side without the capture of any piece and without the movement of any pawn. This number of 50 moves can be increased for certain positions, provided that this increase in number and these positions have been clearly announced by the organisers before the event starts. The most extreme case yet known of a position which might take more than 50 moves to win is king, rook and bishop against king and two knights, which can run for 223 moves between captures!

Von Neumann and Morgenstern, 1944 In chess there is no element of chance, and since each opponent has “prefect information” at each move: For any given position, either: A won position for White. That is, White can force a win, however Black defends. A draw position. White can force at least a draw, however Black plays, and likewise Black can force at least a draw, however White plays. If both sides play correctly the game will end in a draw. A won position for Black. Black can force a win, however White plays.

Von Neumann and Morgenstern, 1944 Nature of existence theorem No practical method is known to determine which of the three is correct If would be determined, probably would lose interest in chess

Altering the rules… A slight change of the rules, guarantees at least a draw for white. Suggested change: A player may choose to “pass”. Proof: If white has a winning move – make it. Otherwise – choose to “pass”. By the symmetry Black is faced with the same position white just had… Since white had no winning move before, Black has none now. Hence, black at best can draw

Evaluation function - f(P) Sometimes a simple evaluation function can be applied to any position P to determine whether it is a won/lost/drawn position Example: The game of NimNim If number of ones in each column binary representation) is even, the player about to move looses f(P) = +1, won position 0, drawn position -1, lost position

Evaluation function - f(P) It is possible, in principle, to play a perfect game. However…  In typical chess position there are legal moves.  One move for white, and one for black yields 10^3 possibilities  Typical game lasts ~40 moves to resignation of one party  Need to check 10^120 variations… infeasible… It is easy to play a trivial game – not interesting.

Approximating Evaluation Functions The relative values of queen, rook, bishop, knight and pawn are about 9, 5, 3, 3,1, respectively. Mobility - Rooks should be placed on open files. Backward, isolated and doubled pawns are weak. An exposed king is a weakness (until the end game). 200(K-K') + 9(Q-Q') + 5(R-R') + 3(B-B'+N-N') + (P-P') - 0.5(D-D'+S-S'+I-I') + 0.1(M-M') +... f(P) =

Two Players Games One Search Tree for both Players  Even layers – Max Player move  Odd Layers – Min Player move The state evaluated according to evaluation function.

MinMax search strategy Generate the whole game tree. (Or up to a constant depth) Evaluate Terminal states (Leafs) propagate Min-Max values up from leafs Search for MAX best next move, so that no matter what MIN does MAX will be better off

1

1-2

1-2 1

MinMax Complexity For branching factor b and depth search d the complexity is O(b d )

Cuting Off Search We want to prune the tree: stop exploring subtrees with values that will not influence the final MinMax root decision

Alpha Beta Simple Example

Alpha-Beta search cutoff rules Keep track and update two values so far:  alpha is the value of best choice in the MAX path  beta is the value of best choice in the MIN path Rule: do not expand node n when beta <= alpha  for MAX node return beta  for MIN node return alpha

Alpha-Beta Prunning function Max-Value(state,game,alpha,beta) returns minmax value of state if Cutoff-Test(state) then return Eval(state) for each s in Successor(state) do alpha := Max(alpha,Min-Value(s, game,alpha,beta) if beta <= alpha then return beta end; return alpha function Min-Value(state,game,alpha,beta) returns minmax value of state if Cutoff-Test(state) then return Eval(state) for each s in Successor(state) do beta := Min(beta,Max-Value(s, game,alpha,beta) if beta <= alpha then return alpha end; return beta

Complexity In the worst case, no cut-off. The complexity is O(b d ). In practice, O(b d/2 ), with branching factor of b 1/2 instead of b.

Type A Strategy Consider all positions down the min- Max, up to a fixed depth d. For each position in depth d, use some evaluation function to estimate the position Possible to implement using only 3000 bits ! Simple and ineffective

Type A Strategy - Backdraws Type A Strategy is Slow & Weak  ~10^9 evaluations needed after 3 moves (6 plies)  Evaluates positions at unreliable states  Rather limited ‘thinking’  World champion can construct (at best) moves deep

Human Strategies Studied experimentally by De Groot, showed various typical positions to chess masters In certain case the chess master examined sixteen variations, ranging in depth from 1/2 (one Black move) to 4-1/2 (five Black and four White) moves. The total number of positions considered was 44.

Type B Strategy Examine forceful variations out as far as possible and evaluate only at reasonable positions, where some quasi-stability (quiescence) has been established. Select the variations to be explored by some process so that the machine does not waste its time in totally pointless variations.

Quiescence Positions Define a function g(P) of a position which determines whether approximate stability exists: g(P) = 1, g(P) = 0, Otherwise. Variations can be explored until g(P)=0 Making sure we check at least 2 moves and at most 10 moves  any piece is attacked by a piece of lower value or by more pieces than defenses, or  any check exists on a square controlled by the opponent

h(P,M) – Is this move essential? For position P, and move M – evalutate decide whether it is worth exploring: High value:  Check  Captures  Attack on major pieces Medium value:  Developing moves  Defensive moves Low value - other moves should NOT eliminate moves that merely look bad at first sight (piece en prise)

Further Developments.. Opening Book Statistical variation – for position P, create some distribution and play by it Positional vs. Combination Player Endgame Solver Iterative Deepening

Recent Achivements

References Claude E. Shannon, Programming a Computer Playing Chess, Philosophical Magazine, Ser. 7, Vol 41, No. 312 – March 1950 The F.I.D.E. Laws of Chess, S. Russel, P. Norvig, Artificial Intelligence A Modern Approach, Prentice Hall, Lecture notes of Workshop in Reinforcement Learnning 2003/4 by Prof. Yishay Mansour, TAU ChessBase, A short history of computer chess,