1 / 50

How Rebel Plays Chess

How Rebel Plays Chess. Ed Schr öder. Presented by Greg Werner. CSCI-297A Extreme Algorithms. Outline of Presentation. 1. Prerequisites 2. History (Context) 3. Intro to Rebel 4. Rebel Techniques. Prerequisites. Paper written for fellow computer chess programmers.

jtoliver
Télécharger la présentation

How Rebel Plays Chess

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How Rebel Plays Chess Ed Schröder Presented by Greg Werner CSCI-297A Extreme Algorithms

  2. Outline of Presentation 1. Prerequisites 2. History (Context) 3. Intro to Rebel 4. Rebel Techniques

  3. Prerequisites Paper written for fellow computer chess programmers. In order to understand this presentation best, it is necessary to be familiar with a few concepts. 1) A basic understanding of the rules of chess and all valid moves is necessary. 2) A cursory knowledge of general Artificial Intelligence techniques such as trees, Alpha-Beta search, pruning, and heuristic evaluation is assumed. Will not assume knowledge of REBEL program or where it fits into computer chess history.

  4. History (Context) “Paper Machine” Turing was the CPU (White) vs 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.dxc6 0-0 12.cxb7 Rb8 13.Ba6 Qa5 14.Qe2 Nd7 15.Rg1 Nc5 16.Rg5 Bg6 17.Bb5 Nxb7 18.0-0-0 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.

  5. History (Context) MANIAC 1 – Human, Los Alamos 1956: 1.d3 b4 2.Nf3 d4 3.b3 e4 4.Ne1 a4 5.bxa4? [5.Nd2 and 6.Nd2-c4+ Nbcxc4 7.b3xc4 with a good game] 5...Nxa4 6.Kd2? Nc3 7.Nxc3 bxc3+ 8.Kd1 f4 9.a3 Rb6 10.a4 Ra6 11.a5 Kd5 12.Qa3 Qb5 13.Qa2+ Ke5 14.Rb1 Rxa5 15.Rxb5 Rxa2 16.Rb1 [to prevent 16...Ra1 mate!] 16...Ra5 17.f3 Ra4 18.fxe4 c4 19.Nf3+ Kd6 20.e5+ Kd5 21.exf6Q Nc5 22.Qf6xd4+ Kc6 23.Nf3-e5 mate. Reduced 6x6 board (sans bishops) which took 12 minutes per 4-ply search. First time computer intelligence beat a human player (though the player had learned to play just one week prior)

  6. History (Context) 1994 London – Kasparov played white 1. c4 c6 2. d4 d5 3. Nf3 Nf6 4. Qc2 dxc4 5. Qxc4 Bf5 6. Nc3 Nbd7 7. g3 e6 8. Bg2 Be7 9. O-O O-O 10. e3 Ne4 11. Qe2 Qb6 12. Rd1 Rad8 13. Ne1 Ndf6 14. Nxe4 Nxe4 15. f3 Nd6 16. a4 Qb3 17. e4 Bg6 18. Rd3 Qb4 19. b3 Nc8 20. Nc2 Qb6 21. Bf4 c5 22. Be3 cxd4 23. Nxd4 Bc5 24. Rad1 e5 25. Nc2 Rxd3 26. Qxd3 Ne7 27. b4 Bxe3+ 28. Qxe3 Rd8 29. Rxd8+ Qxd8 30. Bf1 b6 31. Qc3 f6 32. Bc4+ Bf7 33. Ne3 Qd4 34. Bxf7+ Kxf7 35. Qb3+ Kf8 36. Kg2 Qd2+ 37. Kh3 Qe2 38. Ng2 h5 39. Qe3 Qc4 40. Qd2 Qe6+ 41. g4 hxg4+ 42. fxg4 Qc4 43. Qe1 Qb3+ 44. Ne3 Qd3 45. Kg3 Qxe4 46. Qd2 Qf4+ 47. Kg2 Qd4 48. Qxd4 exd4 49. Nc4 Nc6 50. b5 Ne5 51. Nd6 d3 52. Kf2 Nxg4+ 53. Ke1 Nxh2 54. Kd2 Nf3+ 55. Kxd3 Ke7 56. Nf5+ Kf7 57. Ke4 Nd2+ 58. Kd5 g5 59. Nd6+ Kg6 60. Kd4 Nb3+ 0-1 Chess Genius (Richard Lang) beats Kasparov for first defeat of grand master in a tournament game.

  7. Introduction to Rebel • REBEL was created in 1985 by Ed Schroeder. • He worked on chess until his retirement in 2006. • World Champion 1991-1995 (claimed by Schroeder, more research needed.) • Death was induced by introduction of null-move heuristic.

  8. Introduction to Rebel Courtesy of http://grappa.univ-lille3.fr/icga/game.php?id=1

  9. Introduction to Rebel 1997 – REBEL defeats Arthur Yusupiv 10.5 – 6.5 1998 – REBEL defeats Vishay Anand (elo 2795) 5 - 3

  10. Basic Definitions Quiescent Search – Searching certain noisy roots beyond the standard depth Horizon Effect – Missing a move just beyond the standard depth Null Move Heuristic – If ply 0 were allowed to pass, what plays in ply 1 would not be made (because they are bad plays). Zugzwang – Forced to make bad move

  11. Basic Definitions Killer Heuristic – Repeat very good move at similar depth elsewhere in game tree. Search Extension – Extended the search by 1 (or more ply) in certain situations Bitboard – 8x8 binary representation of board Iterative Deepening – Searching each level of tree until some depth d (with a particular move ordering)

  12. Basic Definitions Futility Pruning – Checking frontier nodes to see if they can be skipped and quiescent search can be applied Frontier Node – Nodes which are one level depth above the quiescence threshold Aspiration Alpha Beta Search – Alpha Beta Search with a narrow search windows

  13. Rebel Techniques 1 Move Ordering 2 Search Techniques 3 Extensions 4 Selective Search 5 Quiescent Search 6 Evaluation 7 King Safety

  14. Move Ordering At the next ply, all moves are generated 12 piece squares are created (black and white * 6 pieces) each storing from and to values along with computed diff value. Search then takes highest move ordering value to determine which path to take first. Factor of 2X speed when this portion is included in the code.

  15. Move Ordering Generate_All_Moves() Update_All_Moves() (optional) Reduce_Depth() - When hash table or winning capture not reported by the update all moves. 13-14% speedup by lowering remaining depth by factor of 2 in subtree before full unsorted tree is searched. Get_Highest_Moves() Do_Something()

  16. Move Ordering 127 – Hash Table Value 126 – Mate Killer Move. A Killer Move that has mate value in tree. 122-124 – Winning Capture (hanging pieces) In case of tie, always favor lower value pieces because it can result in a 5% speedup. Hanging piece (en prise) are pieces which are undefended. 121 – Queen Promotion with capture 120 – Queen Promotion sans capture 119 – Good Capture: Queen Captures Queen 118 – Good Capture: Rook Captures Rook 117 – Good Capture: Knight Captures Bishop 116 – Good Capture: Bishop Captures Bishop 115 – Good Capture: Bishop Captures Knight 114 – Good Capture: Pawn Captures Pawn 110 – Killer-One current ply: Best moves from search for a given ply. Do not include captures, promotions, or winning materials moves. Killer-one is best move 109 – Historic Mate Killer – 3-4% speedup. Mate-score during search. Store the value furthest in the the future in this slot. 108 – Killer-One ply-2 106 – Killer-Two current ply: Killer-two is second best move. Make sure Killer-two is not Killer-one 104 – Killer-Two ply-2 103 – 0-0 102 - 0-0-0 101 – Minor promotions – (Necessary to prevent stalemates in a few cases) -70 Everything else. Gives away material subtracts 30. If causes hanging pieces add 30.

  17. Search Techniques Alpha Beta Lazy EVAL Futility Pruning Horizon Search Reductions

  18. Alpha Beta Aspiration Alpha Beta with 0.5 basic value: a) Fail-high or fail-low results in 2.00 basic value instead of going to ply-1. This catches many of the cases that 0.50 does not catch. Should 2.00 fail as well, then we proceed to ply-1 as before. b) Best score of previous ply stored. Beta narrowing takes places, especially in the case of a small decline in score.

  19. Lazy EVAL Attempt to estimate the evaluation heuristic without considering every single factor There is a margin involved in comparing alpha with score Can be used in: a) Horizon Depth b) Quiescent Search

  20. Futility Pruning Used at horizon -1 and horizon – 2 depth levels Here is the pseudocode for futility pruning: if (current_depth == horizon_depth – 1) { if (king in check) SKIP; if (move checks opponent king) SKIP; if (move captures opponent) SKIP; is (special case) SKIP; FUTILITY(); if (ALPHA < SCORE + MARGIN) can not use; PRUNE THE TREE; }

  21. Horizon Search Avoid quiescent search at all costs! if (LAZY_EVAL) return score (avoiding EVAL and QS) Evaluate_Position(); if (current_depth == max_depth) return score (no QS) if (TRICK_ONE) return score (no QS) // (MARGIN SETTING) if (check opponent king) goto QS if (ALPHA >= SCORE) return score (no QS) if (TRICK_TWO) return score (no QS) // (AUTHOR FORGETS) QS: Quiescent Search()

  22. Reductions Reduce the ply to search by 1. The author gives 5 separate cases to reduce

  23. Reductions if (remaining_depth > 2 && own_king_not_in_check && move is not a capture && move does not check opponent king) { if (ALPHA > SCORE + MARGIN) REDUCE BY 1 } SCORE = // calculate new score (material + piece-square value) MARGIN = // lookup remaining depth to get the value

  24. Reductions Skip if : a) Reduction already taken place b) Own king in check c) Move would place opponent in check d) Material is won by move e) Pressure increased on king if (current_move is hash table move) do not reduce else { if (ALPHA < hash_table_score) do not reduce; else if (hash_table_score – evaluation_score > 0.50) do not reduce; else reduce; }

  25. Reductions if (remaining_depth <=x && remaining_depth > 1) { if (ALPHA > SCORE + THREAT && ALPHA < SCORE + THREAT + MARGIN) then reduce 1 ply }

  26. Reductions if (remaining_depth <=x && remaining_depth > 2) { if (ALPHA > SCORE + THREAT && ALPHA < SCORE + THREAT + MARGIN) then reduce 2 ply }

  27. Reductions if (winning_capture exists, but this move is not a capture) { if (threat_progress_is_made) do not reduce; if (remaining_depth <= 2) do not reduce; if (current_move is in hash table) do not reduce else { if (ALPHA < hash_table_score) { do not reduce; } if (hash_table_score – evaluation_score > 0.50) { do_not_reduce; } else { reduce; } } }

  28. Extensions Checks Recaptures Pawns Endgame King Safety

  29. Checks 100-150 ELO points gain When the current ply move needs to be move out of check, an additional 1 ply of searching can be attained because of the limited scoped of the current ply. In particular, the first check found is ignored and the fourth check is given 2 ply additional searching as a means to tweak this feature

  30. Recaptures 30 – 40 ELO points gain 2.2 -2.5 times slowdown Deeper in the tree, less likely to use If (move_already_extended) do not extend; if (previous_ply_was_no_capture) do not extend; // duh, definition of recapture if (move_does_not_capture_same_square) do not extend; if (move_not_winning_capture) do not extend; if (outside window) do not extend; // uses LOW with HIGH + piece value depth-1 otherwise extend analysis by 1 ply.

  31. Pawns A very simple extension not explained in detail. Whenever a pawn is one rank short of promotion, it gets extended by 1-ply.

  32. Endgame The author notes that this extension is very powerful. Simple endings get extended by 1-ply. These are rook and/or bishop/knight endings. Pawn endings get extended by 3-ply. This one is a bit more involved and the pseudocode is as follows: if (no_capture) do not extend; if (no_pawn_extending) do not extend; if (ISCORE not in +/- 3 range) do not extend; otherwise extend

  33. King Safety 5-10 ELO Point Gain 5% slowdown Pressure (but not checks) are evaluated Exact algorithm not given by author

  34. Selective Search Composed Of: Null Move Static Evaluation Rebel has favored selective search by static evaluation over pure brute force methods Even after “discovery” of null-move heuristic, REBEL kept its static evaluation portion.

  35. Selective Search Game divided into three portions 1) Middle game 2) End game 3) Late end game Each stage has its own analysis table In general, null-move is applied at earlier plies and static evaluation at later plies

  36. Null-Move REBEL attempts to avoid the expense of null-move search Able to avoid full search 93-95% of the time Some sacrifice in quality of move ordering is given up for a nice speedup factor.

  37. Static Evaluation Very dangerous section of code potentially because of the pruning which could take place This section of code is what made REBEL dominant until about 1995 or 1996 Do we do full search of the tree depends on: if (own_king_in_check) return TRUE; if (move_checks_opponent) return TRUE; if (move_is_winning_capture) return TRUE; if (ALPHA < SCORE + THREAT + MARGIN) return true; if (pawn move to 2nd or 3rd to last rank) return true; if (move_threatens_opponent's king) return true; prune if we have reached here

  38. Quiescent Search Two goals are present: Is evaluation of horizontal depth immune from surprises. SCORE decreases. Check for possible series of mating moves. SCORE increases

  39. Quiescent Search All captures are not evaluated in QS, which is a difference between REBEL and other chess engines. Instead, winning captures, equals captures, and queen promotions are the only ones evaluated. The order of analysis in QS is 1st winning capture, 2nd equal capture, and finally checking moves. Queen promotions have been grouped into the winning capture by the author.

  40. Quiescent Search Get a move until no more moves if (Lazy_Eval_is_true) { Evaluate_Position(); return; } else if (Trick_one_is_true) { (Same as Horizon) return; } else if (move_checks_opponent_king) { go_one_ply_deeper } else if (ALPHA >= SCORE) { return } else if (Trick_two_is_true) { (Same as Horizon) return } else { go_one_ply_deeper; }

  41. Quiescent Search When king is in check and only has one or two moves, can significantly increase depth Long check analysis can speedup 14% Example given of a mate in 30 solved

  42. Evaluation Characteristics Hanging Pieces

  43. Characteristics A few hundred evaluation characteristics are used (many not listed in paper) Piece type very important for speed 13 pieces (6 types * 2 colors + 1 empty) An integer-like type (could be short) is used to represent each piece type Switch represented by single jump – C Indexing – Squares tables over fixed values

  44. Hanging Pieces For the side to move, REBEL can detect hanging pieces for up to 3 squares. They are sorted by material loss expectation. A similar thing happens for the opponent, only they are referred to as threatened pieces. A table is maintained for both sides which initially are given 0.0 for all squares. First for the white table, each white piece is analyzed based upon which squares they can move to

  45. Hanging Pieces The value is stored as an 8 bit value already mentioned. Here is the exact determination of value: 3 bits number of attackers (0-7) 1 bit pawn (8) 1 bit knight/bishop (16) 1 bit rook (32) 1 bit queen (64) 1 bit king (128)

  46. Hanging Pieces Overall, a 860 kb data structure is created char TABLE[12][256][256]; If, for a single piece, the status value is not 0, then the piece is considered to be a hanging piece. During start-up, the TABLE is filled with predefined values

  47. King Safety Symmetric algorithm REBEL uses progressive evaluation only in its king safety algorithm The reason the author chooses this is approach is that coherence between would-be king attackers is captured by this method, whereas in a normal evaluation scheme would not.

  48. King Safety Sample progression for King Safety Contibution int EVAL [] = {0, 2, 3, 6, 12, 18, 25, 37, 50, 75,100, 1125, 150, 175, 200, 225, 250, 275, 300, 325,350, 375, 400, 425, 450, 475, 500, 525, 550, 575,600, 600, 600 ,.....}; At first, there is little impact of pressure on the king. Only significant pressure is given any notice. Positional blunders are prevented by this progressive approach

  49. King Safety Three categories of threatened squares are then evaluated in order. A flag value is kept and this flag value provides the lookup to the contribution of the EVAL table.

  50. King Safety Not used when opponent queen has exited board or during the late end game where analysis can actually be hurt by this routine.

More Related