Computer Chess Deep Thought(s) Remembered April 13, 2004 Topics Topics Chip-Test, Deep Thought, Wean Hall Rm8308 Computer Chess Basics Representing the chess board Game search Evaluation function Transposition Table Tricks 15-211 S’04 Chess_211.ppt 15-211
21
Embed
Computer Chess Deep Thought(s) Remembered April 13, 2004
Computer Chess Deep Thought(s) Remembered April 13, 2004. 15-211. Topics Chip-Test, Deep Thought, Wean Hall Rm8308 Computer Chess Basics Representing the chess board Game search Evaluation function Transposition Table Tricks. Chess_211.ppt. 15-211 S’04. Computer Chess at CMU. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Computer ChessDeep Thought(s) Remembered
April 13, 2004
Computer ChessDeep Thought(s) Remembered
April 13, 2004TopicsTopics
Chip-Test, Deep Thought, Wean Hall Rm8308 Computer Chess Basics
Representing the chess boardGame searchEvaluation functionTransposition TableTricks
15-211 S’04Chess_211.ppt
15-211
– 2 – 15-211, S’04
Computer Chess at CMUComputer Chess at CMU
Hans BerlinerHans Berliner World postal chess champion (1968) CS Faculty in AI Backgammon Computer Program Beats World Champion Patsoc, a DEC-10 (mainframe) chess program Hitech
Vs. a bunch of CS graduate studentsVs. a bunch of CS graduate students Feng H. Hsu (Crazy Bird) Thomas Anantharaman Murray Campbell Mike Browne Yours truly
– 3 – 15-211, S’04
Chiptest, Deep Thought TimelineChiptest, Deep Thought Timeline
A VLSI design class project evolves into A VLSI design class project evolves into F.H.Hsu move-generator chipF.H.Hsu move-generator chip
A productive CS-TG results in ChipTest, A productive CS-TG results in ChipTest, about 6 weeks before the ACM computer about 6 weeks before the ACM computer chess championshipchess championship
Chiptest participates and plays interesting Chiptest participates and plays interesting (illegal) moves(illegal) moves
Chiptest-M wins ACM CCCChiptest-M wins ACM CCC
Redesign becomes DTRedesign becomes DT
DT participates in human chess DT participates in human chess championships (in addition to CCC)championships (in addition to CCC)
DT wins second Fredkin Prize ($10K)DT wins second Fredkin Prize ($10K)
DT is wiped out by KasparovDT is wiped out by Kasparov
Story continues@ IBM
– 4 – 15-211, S’04
Opinions: Is Computer Chess AI?Opinions: Is Computer Chess AI?
From Hans Moravec’s Book “Robot”
– 5 – 15-211, S’04
Books to ReadBooks to Read
““Chess Skill in Man and Machine”, ‘84, ISBN: 0387907904Chess Skill in Man and Machine”, ‘84, ISBN: 0387907904 Slate and Atkins describe Slate and Atkins describe Chess 4.5Chess 4.5
F.H.Hsu’s book:F.H.Hsu’s book:
– 6 – 15-211, S’04
Chess Data StructuresChess Data Structures
The chess board:The chess board:
Need some other stuff:Need some other stuff: Castle status En passant status Repetition detection 50 Move rule
Bit-board representation of chess position (see Bit-board representation of chess position (see CraftyCrafty, Hyatt):, Hyatt):
unsigned long long blk_king, wht_king, wht_rook_mv2,…;
a b c d e f g h
8
7
6
5
4
3
2
1
0 1 2
61 62 63
wht_king = 0x0000000000001000ull;blk_king = 0x0004000000000000ull;wht_rook_mv2 = 0x10ef101010101010ull;.../* * Is black king under attach from * white rook ? */if (blk_king & wht_rook_mv2)
printf(”Yes\n”);
– 8 – 15-211, S’04
Legal Move GenerationLegal Move Generation
Chess programs spend a lot of time computing the Chess programs spend a lot of time computing the legal moves for a given positionlegal moves for a given position
Observation: limited number of moves (~5000)Observation: limited number of moves (~5000)
Complication: Move order mattersComplication: Move order matters Capture moves first
Highest valued target firstLowest valued piece first
Pieces under attack Other heuristics
Deterministic order? Yes: can encode move by its sequence number
About 36 moves in midgame
– 9 – 15-211, S’04
Min-Max Tree searchMin-Max Tree search
Limited depth, depth first searchLimited depth, depth first search
Number of Nodes visited ~ (Branching-factor)Number of Nodes visited ~ (Branching-factor)DepthDepth
– 10 – 15-211, S’04
Alpha Beta SearchAlpha Beta Search
Works better at depthWorks better at depth
Branching factor now ~6Branching factor now ~6(depends on even/oddness)(depends on even/oddness)
– 11 – 15-211, S’04
Iterative DeepeningIterative Deepening
Improve move ordering via shallow searchesImprove move ordering via shallow searches
Need to search the same part of the tree multiple times Need to search the same part of the tree multiple times but improved move ordering more than makes up for but improved move ordering more than makes up for this redundancythis redundancy
Difficulty:Difficulty: Time control: each iteration needs about 6x more time What to do when time runs out?
8 R N B Q K B - R 7 P P P - * - P P 6 - * - * P N - * 5 * - * P * P * - 4 - * - p - * - * 3 * - * - * n p - Ex =-6 2 p p p * p p b p E0 =29 1 r n b q * r k - E =
Deep Thought’s Evaluation FunctionDeep Thought’s Evaluation Function
Implemented in Xilinx FPGA’s, heavy use of look-up Implemented in Xilinx FPGA’s, heavy use of look-up tables (Piece placement table, etc…)tables (Piece placement table, etc…)
Material weighting to adapt to game phasesMaterial weighting to adapt to game phases
Notable deficiencies:Notable deficiencies: No Mobility term No Square control term
Made up by speed!Made up by speed!
– 16 – 15-211, S’04
Deep Blue’s Eval functionDeep Blue’s Eval function
Over 10,000 FeaturesOver 10,000 Features
How do you determine the proper weights???How do you determine the proper weights???
– 17 – 15-211, S’04
Evaluation Function TuningEvaluation Function Tuning
Given data base of Grand-Master games: goal tune the Given data base of Grand-Master games: goal tune the weights such that DT chooses the move made by the weights such that DT chooses the move made by the GMGM
Idea: Symbolic evaluation of differences between Idea: Symbolic evaluation of differences between Positions (see Positions (see http://www.tim-mann.org/deepthought.htmlhttp://www.tim-mann.org/deepthought.html ))
– 18 – 15-211, S’04
Transposition TableTransposition Table
Chess isn’t really a tree:Chess isn’t really a tree:
Compute hash function incrementally via piece position Compute hash function incrementally via piece position table full of “random” numbers:table full of “random” numbers: Remove pawn from a4: Add pawn to a5:
Transposition table content:Transposition table content: Actual position (optional) Depth Value Other flags
Pos_hash ^= rnd_tab[pawn][a4];
Pos_hash ^= rnd_tab[pawn][a5];
– 20 – 15-211, S’04
Useful Real Life ApplicationUseful Real Life Application
Memory Model checkerMemory Model checker
/* * Basic loop test */
Processor 0: (0) st #1,[a]Processor 1: (1) st #0,[a] (2) loop: ld [a],%r (3) cmp #1,%r bne loop (4) st #2,[a]
Possible values under all memory models:1:r a example sequence of events 0 0 1i0 0i0 2.0 0p0 3.0 2.1 1p0 3.1 2.2 3.2 ... loop via P2:loop 1 2 1i0 0i0 2.0 1p0 3.0 2.1 0p0 3.1 2.2 3.2 4i0 4p0
– 21 – 15-211, S’04
TricksTricks
Many tricks and heuristics have been added to chess Many tricks and heuristics have been added to chess program, including this tiny subset:program, including this tiny subset:
Opening BooksOpening Books
Avoiding mistakes from earlier gamesAvoiding mistakes from earlier games