Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Chess Deep Thought(s) Remembered April 13, 2004

Similar presentations


Presentation on theme: "Computer Chess Deep Thought(s) Remembered April 13, 2004"— Presentation transcript:

1 Computer Chess Deep Thought(s) Remembered April 13, 2004
15-211 Computer Chess Deep Thought(s) Remembered April 13, 2004 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 S’04

2 Computer Chess at CMU Hans 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 students Feng H. Hsu (Crazy Bird) Thomas Anantharaman Murray Campbell Mike Browne Yours truly

3 Chiptest, Deep Thought Timeline
A VLSI design class project evolves into F.H.Hsu move-generator chip A productive CS-TG results in ChipTest, about 6 weeks before the ACM computer chess championship Chiptest participates and plays interesting (illegal) moves Chiptest-M wins ACM CCC Redesign becomes DT DT participates in human chess championships (in addition to CCC) DT wins second Fredkin Prize ($10K) DT is wiped out by Kasparov Story continues @ IBM

4 Opinions: Is Computer Chess AI?
From Hans Moravec’s Book “Robot”

5 Books to Read “Chess Skill in Man and Machine”, ‘84, ISBN: Slate and Atkins describe Chess 4.5 F.H.Hsu’s book:

6 Chess Data Structures The chess board: Need some other stuff:
Castle status En passant status Repetition detection 50 Move rule #define EMPTY 0 #define EMPTY2 8 #define PAWN 1 #define KNIGHT 2 #define BISHOP 3 #define ROOK 4 #define QUEEN 5 #define KING 6 #define WPAWN 1 #define WP 1 #define WKNIGHT 2 #define WN 2 #define WBISHOP 3 #define WB 3 #define WROOK 4 #define WR 4 #define WQUEEN 5 #define WQ 5 #define WKING 6 #define WK 6 #define BPAWN 9 #define BP 9 #define BKNIGHT 10 ... unsigned char board[8][8];

7 Fun with Bitvectors Bit-board representation of chess position (see Crafty, Hyatt): unsigned long long blk_king, wht_king, wht_rook_mv2,…; 8 7 6 5 4 3 2 1 1 2 wht_king = 0x ull; blk_king = 0x ull; wht_rook_mv2 = 0x10ef ull; ... /* * Is black king under attach from * white rook ? */ if (blk_king & wht_rook_mv2) printf(”Yes\n”); 61 62 63 a b c d e f g h

8 Legal Move Generation Chess programs spend a lot of time computing the legal moves for a given position Observation: limited number of moves (~5000) Complication: Move order matters Capture moves first Highest valued target first Lowest valued piece first Pieces under attack Other heuristics Deterministic order? Yes: can encode move by its sequence number About 36 moves in midgame

9 Min-Max Tree search Limited depth, depth first search
Number of Nodes visited ~ (Branching-factor)Depth

10 Alpha Beta Search Works better at depth
Branching factor now ~6 (depends on even/oddness)

11 Iterative Deepening Improve move ordering via shallow searches
Need to search the same part of the tree multiple times but improved move ordering more than makes up for this redundancy Difficulty: Time control: each iteration needs about 6x more time What to do when time runs out?

12 Limited Depth Search Problems
Horizon effect: push bad news over the search depth Quiescence search: can’t simply stop in the middle of an exchange

13 Evaluation Function Guesses the outcome of an incomplete search
Eval(Position) = i wi * fi(Position) Weights wi may depend on the phase of the game Features fi: #of Pawns (material terms) Centrality Square control Mobility Pawn structure Many more …

14 Deep Thought’s Evaluation Function
File: dbf_all game: 0 (drawn) move-#: 5 side-to-move: W move: o-o ( 1/1 ) 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 = a b c d e f g h BadBishop * 0= KingShelter *-256= 4 PPCentral * 0= RookOpenTrop * 0= Backward * 0= KingShelter * 256= 26 PPCentral * 0= RookSemi * 0= Backward * 0= KnightCentrality * 0= PawnPlaceA *-102= -5 RookSemi * 0= BishopBlock * 0= KnightCentrality * 0= PawnPlaceC * 0= RookSemiTrop * 0= BishopDefense * 0= KnightCentrality * 0= PawnPlaceCA *-102= 5 RookSemiTrop * 0= BishopDefense * 0= KnightDefense * 0= PawnPlaceK * 0= RookValue K! 0= BishopPlacement * 768= 7 KnightDefense * 0= PawnPlaceM * 0= SingleIsoClosed * 0= BishopPlacement * 768= 1 KnightInCorner * 0= PawnPlaceMA *-102= 4 SingleIsoClosed * 0= BishopPlacement * 768= 0 KnightInCorner K5* 0= PawnPlaceMC * 0= SingleIsoOpen * 0= BishopValue K5! 0= KnightTropism * 0= PawnPlaceMCA *-102= -17 SingleIsoOpen * 0= BlockedKingShelter0 -27* 0= KnightTropism * 0= PawnValue K2! 0= TripleClosed K3* 0= BlockedKingShelter1 21* 0= KnightValue K3! 0= PawnValue * 0= TripleClosed * 0= DoubleClosed * 0= NoBishopPawn * 0= QueenCentrality * 0= TripleIsoClosed0 2K0* 0= DoubleClosed * 0= NoBishopPawn * 0= QueenCentrality * 0= TripleIsoClosed1 -1K0* 0= DoubleIsoClosed * 0= NoKnightPawn * 0= QueenCentrality * 0= TripleIsoOpen K0* 0= DoubleIsoClosed * 0= NoKnightPawn * 0= QueenTropism * 0= TripleIsoOpen * 0= DoubleIsoOpen * 0= NoRookPawn * 0= QueenTropism * 0= TripleOpen K3* 0= DoubleIsoOpen * 0= NoRookPawn * 0= QueenValue K! 0= TripleOpen * 0= DoubleOpen * 0= OneBishop * 0= RookOnSeventh * 0= TwoBishop * 0= DoubleOpen * 0= OneBishop * 0= RookOnSeventh * 0= TwoBishop * 0= KingCentrality *-512= -8 PPAdvance * 0= RookOpen * 0= KingCentrality *-512= 6 PPAdvance * 0= RookOpen * 0= KingCentrality *-512= 7 PPAdvance * 0= RookOpenTrop * 0=

15 Deep Thought’s Evaluation Function
Implemented in Xilinx FPGA’s, heavy use of look-up tables (Piece placement table, etc…) Material weighting to adapt to game phases Notable deficiencies: No Mobility term No Square control term Made up by speed!

16 Deep Blue’s Eval function
Over 10,000 Features How do you determine the proper weights???

17 Evaluation Function Tuning
Given data base of Grand-Master games: goal tune the weights such that DT chooses the move made by the GM Idea: Symbolic evaluation of differences between Positions (see )

18 Transposition Table Chess isn’t really a tree:

19 Transposition Table Maintenance
Compute hash function incrementally via piece position table full of “random” numbers: Remove pawn from a4: Add pawn to a5: Transposition table content: Actual position (optional) Depth Value Other flags Pos_hash ^= rnd_tab[pawn][a4]; Pos_hash ^= rnd_tab[pawn][a5];

20 Useful Real Life Application
Memory 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] Program execution flow: 0i0 < 0p0 1i0 < 1p0 < 2.0 < 3.0 < 4i2 < 4p2 ^ 2.1 < 3.1 < 4i1 < 4p1 2.2 < 3.2 < 4i0 < 4p0 Possible values under all memory models: 1:r a example sequence of events i0 0i p p loop via P2:loop i0 0i p p i0 4p0

21 Tricks Many tricks and heuristics have been added to chess program, including this tiny subset: Opening Books Avoiding mistakes from earlier games Endgame databases (Ken Thompson) Singular Extensions Think ahead Narrow window searches Contempt factor Strategic time control


Download ppt "Computer Chess Deep Thought(s) Remembered April 13, 2004"

Similar presentations


Ads by Google