Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1...
-
Upload
augustus-gordon -
Category
Documents
-
view
213 -
download
0
Transcript of Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1...
![Page 1: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/1.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 1
Computer Chess
Chess is the game most intensively studied thus far by the AI community.
• In 1965, it was called the Drosophila of Artificial Intelligence (by Russian mathematician Alexander Kronrod)
![Page 2: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/2.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 2
Computer Chess
Chess is the game most intensively studied thus far by the AI community.
• In 1965, it was called the Drosophila of Artificial Intelligence (by Russian mathematician Alexander Kronrod)
• In 1997, John McCarthy commented on this:
• “However computer chess has developed as genetics might have if the geneticists had concentrated their efforts starting in 1910 on breeding racing Drosophila. We would have some science, but mainly we would have very fast fruit flies.”
![Page 3: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/3.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 3
Computer Chess
Chess is the game most intensively studied thus far by the AI community.
• In 1965, it was called the Drosophila of Artificial Intelligence (by Russian mathematician Alexander Kronrod)
• In 1997, John McCarthy commented on this:
• “However computer chess has developed as genetics might have if the geneticists had concentrated their efforts starting in 1910 on breeding racing Drosophila. We would have some science, but mainly we would have very fast fruit flies.”
• Anon said: “If you can’t beat your computer at chess, try kickboxing.”
![Page 4: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/4.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 4
Computer Chess
Chess is the game most intensively studied thus far by the AI community.
• In 1965, it was called the Drosophila of Artificial Intelligence (by Russian mathematician Alexander Kronrod)
• In 1997, John McCarthy commented on this:
• “However computer chess has developed as genetics might have if the geneticists had concentrated their efforts starting in 1910 on breeding racing Drosophila. We would have some science, but mainly we would have very fast fruit flies.”
• Anon said: “If you can’t beat your computer at chess, try kickboxing.”
• and “At times it seems that all what we have achieved in 40 years of computer chess research is to drop the prediction time from ‘sometime in the next decade’ to ‘in the next three years’.”
![Page 5: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/5.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 5
Highpoints of Computer Chess history
•1950:Claude Shannon writes Programming a Computer for Playing Chess, introduces
minimax, Type A (search based) and Type B (knowledge based) programs.
•1951:Alan Turing creates & hand-simulates a B program, it loses to a weak player.
• 1956, 1957: A- and B- Programs implemented on computers, getting better
•1958: Alpha-beta pruning introduced, it greatly reduces the work involved in tree search,
enabling deeper search.
•1967: MacHack-6 competes in 4 amateur chess tournaments, wins 3, draws 3, loses 12
•1973: Chess 4.0 wins computer tournament comfortably, others start switching to type A
•1977:Belle, with special-purpose hardware, beats a Grandmaster at speed chess.
•1988: Deep Thought defeats a Grandmaster in a tournament.
•1996: Deep Blue beats reigning champion Kasparov in the first game of a six-game
match, but loses the match.
•1997: Improved Deep Blue defeats Kasparov, though he did not play at his best.
![Page 6: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/6.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 6
Shannon Types A, B
•Type A programs work by (or as if by) exploring all moves in a game tree to a uniform depth.
•Type B programs choose parts of a game tree to explore,
• doing selective move generation
• using chess knowledge (rules, learned weights, patterns & statistics)
to distinguish promising lines of play to be explored further
from poor lines of play to be explored no further
(“Quiescence Search” complicates this simplistic picture, but it is not considered enough to turn an A program into a B one)
Shannon believed Type B clearly superior, but (in chess anyhow) experience has not borne this out.
![Page 7: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/7.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 7
ELO Ratings for human players
800 - Beginner
1400 - Class D or C
1600 - Class C or B
1800 - Class B or A
2000 - Class A or Expert
2200 - Expert or National Master
2300 - National Master
2520 - International Master
2600 - Grandmaster
2700+ - Super Grandmaster
Each extra 100 points corresponds roughly to expecting to win two games out of three: approx 20 such steps from beginner to champion.
![Page 8: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/8.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 8
Gross Anatomy of a chess program
•User Interface - most probably a GUI but this is not strict requirement
•Representations
• For board positions (perhaps also, parts of board positions)
• For moves (whether played or merely imagined)
•Chess Engine
• Judge legality of user-input moves
• Effect board position changes in response to moves
• Allow retraction of moves (for user convenience, also for search)
• Means of selecting moves for computer player
Game-Tree Search: often alpha-beta with several refinements
Evaluation Function: often dominated by material gains/losses
Opening book
Endgame database
![Page 9: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/9.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 9
GUI example
![Page 10: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/10.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 10
Representations required
Board Positions:
•Board-Centric:
• Chess board has 64 squares, each may be empty or occupied by one of twelve kinds of chessmen.
• Therefore one may use an 2-d 8x8 array (or 1-d 64-vector) of 4-bit values, (or several bitboards to be described in a future lecture).
•Piece-Centric:
• A player has 16 men, each is either captured or on one of 64 squares.
• Therefore one may use a 1-d 16-vector of 7-bit values.
Moves:
•A chessman belonging to one player moves from one square to another.
•Therefore one may use a pair (FromSquare, ToSquare) of 6-bit numbers.
•But …
![Page 11: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/11.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 11
Requirements of representations
The rules of chess have two oddities that spoil this simple representation of moves (and piece-centric board representations too)
• Castling:
• Subject to certain provisos, a king K and a rook R may move simultaneously Each K just once per game, neither it nor R has yet moved, K is not
moving out of check or through check, all spaces empty between K & R
• K may normally only move one square; in castling it moves two squares.
• Special logic could handle the implied R movement of a 2-square K move.
• Pawn Promotion:
• A pawn that reaches the 8th rank is replaced with another piece: Queen Rook Bishop or Knight
• Piece-Centric board representation now needs to say what type of piece
• (FromSquare, ToSquare) pair needs extra WhatPieceNow element
![Page 12: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/12.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 12
Chess Engine element: The Rules
The rules of movement and capture need to be represented:
•Different pieces may move in different ways:
• Pawn: forward two empty squares from its starting position;
• Pawn: one empty square forward from any position;
• Bishop: diagonally any direction any number of empty squares;
• Rook: forward backward or sideways any number of empty squares;
• Queen: diagonally like bishop or to-or-fro-or-sideways like rook;
• Knight: one square forward or back plus two sideways, or vice versa
• King: to any of eight adjacent squares, or special castling move.
•All pieces except pawns may capture an opposing piece by finishing their movement where it is. The opposing piece is removed.
• Pawns capture with a one-square forward-diagonal;
• There is an en-passant rule too. Read all about it!
![Page 13: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/13.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 13
Chess Engine element: Make Move and Retract Move
•User-input moves, and Computer-Generated responses, must have the correct effect, and be reflected in the GUI.
•Interactive users should be given the opportunity to Undo a pair of moves.
• Therefore, Move Representation must include information on captures too, so that a captured piece can be reinstated by Undo.
•The Make-Move and Retract-Move functionality is needed also, intensively, while the computer player is searching the game tree
• Must therefore be fast
• Will not involve GUI
![Page 14: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/14.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 14
Chess Engine element: Game-Tree search
The full game tree for chess is so large that it is not feasible to search for the winning move.
•Estimates of 101050 possible games, 1040 possible positions
•Typical game: each player has around 50 moves, around 38 choices each time
• 38100
Shannon Type A programs would use Minimax algorithm, to a fixed depth, backing up values heuristically computed by an evaluation function.
The deeper the search, the better the play.
There are many refinements to the basic Minimax, and some alternatives to it:
![Page 15: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/15.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 15
Beyond Minimax
Refinements:
• Alpha-Beta, Progressive Deepening, Principal Variation Search,
• Transposition Tables,
• Quiescence Search,
• Principal Variation Search (NegaScout), Scout, Aspiration Search, MTD(f),
• Killer Heuristic, History Heuristic, NullMove Heuristic,
• Selective Extensions.
Alternatives:
• Conspiracy Number Search, Proof Number Search,
• B*,
• Monte-Carlo rollouts, UCT.
![Page 16: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/16.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 16
Chess Engine element: Evaluation Function
An evaluation function provides a number which indicates how good a position is for one player.
• This is vague, but should not be treated as probability of a win.
• Evaluation function will be heavily used in search, so should be fast.
Evaluation functions for chess are typically dominated by material balance.
Typical values: Pawn 1; Bishop 3; Knight 3; Rook 5; Queen 9; King infinite.
Other features taken into account too:
•Control of the centre four squares
•Passed pawns
•Mobility, especially of the queens.
• The sum of possible value of all other features combined is typically regarded as no more than 1.5 pawns
![Page 17: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/17.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 17
Chess Engine element: Opening book
It quickly proved too hard to select good opening moves using limited search and an evaluation function.
•Centuries of human experience are codified in opening books which serious players study.
•Chess programs use the knowledge in these publications,
• perhaps augmented by team members expert or better in chess,
• coded by programmers into a form their program can use.
•A common strategy of human players confronting computers is to make moves out of the book - i.e. not found in the book - in the expectation that the computer will not be able to find the responses which make the move sub-optimal.
![Page 18: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/18.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 18
Chess Engine element: Endgame databases
An Endgame database is a tabulation of the possible positions in which only a very small number of chessmen remain on the board. For each position, it records the best move.
Examples are:
King and Pawn versus King (KPK)
King and Rook versus King (KRK)
King Rook and Pawn versus King and Rook (KRPKR)
Some endgame databases did exist, as books, before computer chess.
But Computer Chess has contributed enormously to the chess world’s knowledge of several endgames, through exhaustive analysis of positions too numerous for humans to tabulate. Championship contenders have been known to consult computer-generated databases overnight during an adjourned game.
![Page 19: Http://csiweb.ucd.ie/Staff/acater/comp30260.htmlArtificial Intelligence for Games and Puzzles1 Computer Chess Chess is the game most intensively studied.](https://reader036.fdocuments.in/reader036/viewer/2022071805/56649cdf5503460f949a901d/html5/thumbnails/19.jpg)
http://csiweb.ucd.ie/Staff/acater/comp30260.html Artificial Intelligence for Games and Puzzles 19