1 / 57

Computer Chess

Pasi Fränti. Computer Chess. 5.5.2016. History. Mechanical Turk [von Kempelen, 1770] Computer Chess problem and Minmax search [Shannon, 1950] Turings Chess test Deep Blue wins Garry Kasparov [1987] Best computers today (~3200); Magnus Carlsen (2853)

tblanche
Télécharger la présentation

Computer 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. Pasi Fränti Computer Chess 5.5.2016

  2. History • Mechanical Turk [von Kempelen, 1770] • Computer Chess problem and Minmax search [Shannon, 1950] • Turings Chess test • Deep Blue wins Garry Kasparov [1987] • Best computers today (~3200);Magnus Carlsen (2853) • Machine learning for optimizingweights of material and positional factors

  3. Pieces and board

  4. Move notations

  5. Minmax search

  6. Chess game as search tree

  7. Minmax searchFixed depth 3 17 12 15 25 0 2 5 3 2 14 2 https://www.youtube.com/watch?v=fJ4uQpkn9V0

  8. Materialtypical values 9 3 3 5 1

  9. Alpha-beta pruning  Upper bound  Lower bound Terminate when < Max! Min! =3 Max! =2 3 2 Min! Min! 3 17 15 25 0 2 5 3 2 14 2

  10. Alpha-beta pruning Max! =3 Min! 15 =15 3 Max! 15 3 2 3 17 15 2 5 3 2 14 2

  11. Alpha-beta pruning =3 Max! 3 =3 Min! =3 15 3 Max! 15 =2 3 2 2 Min! 3 17 15 2 3 2 14 2

  12. Alpha-beta pruning Final result: 3 =3 3 Max! 3 3 Min! 15 3 3 15 3 2 2 3 3 17 15 2 3 2

  13. Order of moves • Very important! • More accurate value  More can be pruned • If branch of best move (oracle!) always searched first, branching factor  n • Assume fixed amount of time allowed: d = search dept of minmax e = search dept of alpha-beta n = number of moves n e n d Twice as deep!

  14. Heuristics for ordering • If the same position reached again; use the previous best move to search first again. • If a move was found good in sibling node, then assume it is good also in this node. • Capturing higher value piece = GOODCapturing defended lower value piece = BAD • Queen promotions

  15. Examples of captures • Nxe5 Nxe5 -2 • Bxc6 dxc6 • Nxe5 +1 • Nxd5 (+3) cxd5 (+3) • Bxd5 (+1) Bxd5 (+3) • Qxd5 (+3) Qxd5 (+9) • Rxd5 (+9) +1 -2

  16. Horizon effectblack to move Two plies search: • … Bxh2 • Kxh2 Three plies search: • … Nbc5 • cxd7 Nxc7 -2 -2

  17. Horizon effectblack to move Nine ply search: • … b2 • Bxb2 c3 • Bxc3 d4 • Bxd4 e5 • Bxe5 f6 -4

  18. Horizon effectPushing the disaster beyond horizon What can black do?

  19. Quiescent position Search deeper until quiescent position Non-quiescent situations: • Winning captures (or any / major capture) • Checks + evasions of checks • Pawn promotions • Pawn move to 7th rank Earlier used also singular extension

  20. Check is non-quiescent • Material is even • Check is forcing • Black will lose either Queen or another piece

  21. Pawn promotionWhite to play and win 1.e7 Qa3+ 2.Rb4 Qa7+ 3.Kxc4! Qxe7 4.Nxg6+fxg6 5.Bf6+ Qxf6 6.Kd5+Kg5 7.h4+Kf5 8.g4+hxg4 9.Rf4+Bxf4 10.e4#

  22. Pawn promotionWhite wins after 10 moves • All moves since e7 were non-quiescent: • Check • Forced move • Capture • Threat to promote

  23. Limits of non-quiescent Looks quiet…

  24. Limits of non-quiescent 1. Nf6+ gxf6 2. Qg4+ Kh8 3. Kg2 Quiet move but…

  25. Limits of non-quiescent Unstoppable: 4. Rh1X

  26. Evaluation

  27. Material Piece-square tables Pawn structure Piece-specific evaluation Mobility King safety Threat Space Draw-ish-ness Evaluation criteria

  28. Material Basic values 9 5 3 3 1 Double knights Double bishops ?? 6+

  29. Pawn valuesopening Center important Progress

  30. Pawn valuesend game

  31. Piece-square tableKnight     -50,-40,-30,-30,-30,-30,-40,-50,    -40,-20,  0,  0,  0,  0,-20,-40,    -30,  0, 10, 15, 15, 10,  0,-30,    -30,  5, 15, 20, 20, 15,  5,-30,    -30,  0, 15, 20, 20, 15,  0,-30,    -30,  5, 10, 15, 15, 10,  5,-30,    -40,-20,  0,  5,  5,  0,-20,-40,    -50,-40,-20,-30,-30,-20,-40,-50,

  32. Piece-square tableKing during mid-game   -30,-40,-40,-50,-50,-40,-40,-30,  -30,-40,-40,-50,-50,-40,-40,-30,  -30,-40,-40,-50,-50,-40,-40,-30,  -30,-40,-40,-50,-50,-40,-40,-30,  -20,-30,-30,-40,-40,-30,-30,-20,  -10,-20,-20,-20,-20,-20,-20,-10,    20, 20,  0,  0,  0,  0, 20, 20,   20, 30, 10,  0,  0, 10, 30, 20

  33. Piece-square tableend game     -50,-40,-30,-20,-20,-30,-40,-50,    -30,-20,-10,  0,  0,-10,-20,-30,    -30,-10, 20, 30, 30, 20,-10,-30,    -30,-10, 30, 40, 40, 30,-10,-30,    -30,-10, 30, 40, 40, 30,-10,-30,    -30,-10, 20, 30, 30, 20,-10,-30,    -30,-30,  0,  0,  0,  0,-30,-30,    -50,-30,-30,-30,-30,-30,-30,-50

  34. Pawn structure Backward Passed Opposed Passed Lever Unsupported Isolated

  35. Can white promote?

  36. Mobility 4 2 1 3 0 2

  37. King safety

  38. King safety

  39. Transposition table • 1. e4 e5 • 2. Nf3 Nc6 • Nf3 Nc6 • e4 e5 • 1. e4 Nc6 • 2. Nf3 e5 • Castling rights • En passant moves

  40. Collected examples

  41. Opening + end game databases

  42. Opening book • Known games from grand masters. • Include moves played often. • Systematic self-play by computer until pre-defined depth. • Exclude moves leading to bad position.

  43. Deep Blue – Kasparov 1997 Decisive game 6 Kasparov played h6… Ne4 and black has better position Knight sacrifice wins but only if white knows how to play the position. Typical computer chess programs don’t know how to do it.

  44. Deep Blue game 6Continuation of the game 8. Nxe6 Qe7 9. 0-0 fxe6 10. Bg6+ Nine moves later after 19. c5 1-0 black resigns

  45. End game database • Known games from grand masters. • Include moves played often. • Systematic self-play by computer until pre-defined depth. • Exclude moves leading to bad position.

  46. Machine learning

  47. Optimizing by Genetic AlgorithmStudent project by P.Aksenov (Joensuu, Finland) • Population of computer players. • Random initial parameters. • Tournament playing to find fitness. • Crossover for new parameter combies.

  48. Initial value range

  49. Result of optimizationbishop & knight

  50. GiraffeStudent project by M.Lai (London, UK) • Temporal-difference learning: play fixed depth (12 plies). • Fitness based on stability. • Non-linear combination of 363 features. • Optimizes parameters and selection of the next branch in the search.

More Related