Chess Playing Agents: a Problem Analysis
Total Page:16
File Type:pdf, Size:1020Kb
Chess Playing Agents: A Problem Analysis Francisco Mota, Alex Rottinghaus University of Northern Iowa [email protected], [email protected] Abstract based off the positions of the pieces and then deciding In this article we discuss chess as a problem to be on a best move from some heuristic. solved by artificial intelligence. We analyze chess and describe why it is a particularly popular AI 2. Background problem. This article also explores the history of chess playing agents and discusses their advance- The game of chess is played on an 8x8 board with ment over time. We also highlight the competition two sets of pieces representing fictional armies. Each that erupted between chess players and computer set consists of a king, a queen, two bishops, two engineers. We also discuss different algorithms knights, two rooks, and eight pawns. Each type of piece and programming techniques for playing chess. has a specific pattern it can move within. The king also We then offer an opinion of the combination of has a special requirement in that it can’t move into a techniques that are most often used and seem to have the greatest success at making winning chess space that would allow another piece to take it. As agents. players take turns moving their pieces they can capture a piece if they can move into its square while abiding Keywords: Chess Agents, Greenblatt, Deep Blue, by the rules of movement for their attacking piece. The Minimax, Genetic Algorithms game is won when one player positions their pieces such that they can attack the enemy king with one of 1. Introduction their pieces and the king can’t move to a square where it would not be under attack. Another way the game Chess has been used as a demonstration of artificial may end is under stalemate. In a stalemate a player is intelligence since the 1700’s when Wolfgang von stuck so that they can make no legal moves, yet they are Kempelen created a machine he called the Turk (Not so not in check. A stalemate is considered a draw and smart 2003). While Kempelen’s machine was run by a should be avoided in favor of a checkmate. person hidden inside, it was an example of someone When first playing the game, it may appear as though trying to solve the problem of creating a machine to taking an opponent’s piece at every opportunity would play chess. be the way to win. Obviously, the more pieces you have Since that time chess has continued to be a popular compared with your opponent, the easier it will be for method of measuring machine intelligence. As you to trap their king. However, playing only a few computers progress over time people and companies continually try to create faster and better chess playing machines. The reason chess has become so popular may be because it is a game that can be described with a simple set of rules, but yet playing it is so vastly complex that many humans don’t or can’t learn to play it. Computer programmers were interested in intelligence and they needed somewhere to start. So they looked around at who the smartest people were, and they were themselves, of course. They were all essentially mathematicians by training and mathematicians do two things -- they prove theorems and play chess. And they said, hey, if it proves a theorem or plays chess, it must be smart. – (Hamilton 2000) The complexity is what today makes solving chess a great measure of computer intelligence. There are between 10^43 and 10^50 legal chess boards (Lassabe et al. 2006). To create an algorithm to examine a chess Figure 1. A standard chess board with pieces in their board and then reference a database to find the correct starting positions. following move would be impossible with today’s computers. This means that a more clever solution must chess games with an experienced player will quickly be implemented that involves making assumptions show that this is false. Winning the game of chess requires careful planning that focuses not simply on taking enemy pieces, but on arranging your pieces so as improvement from evaluating the whole board every to set up a trap for the enemy king, all the while time a single piece was moved or taken, but it was still preventing a similar trap from being set on your own overkill, for the Los Alamos agent was still evaluating king. every single board position reachable within four ply. In 1958, a chess player and programmer at IBM named Alex Bernstein, came up with an alternative 3. A History of Chess Agents solution. Bernstein’s program, operational in 1958, was Computer chess agents draw their roots back to a also modeled after Shannon’s ideas. Unlike the Los journal article by Claude Shannon (Shannon, 1950) that Alamos program, Bernstein’s program did not consider describes a general framework of a what a chess agent every single move. Bernstein implemented “plausible may look like. At any given turn, a chess agent would move generators” that would only allow his program to have to look at the set of possible moves and calculate consider moves that seemed to make a difference. He which move was best. With simple games, such as Tic- had different generators for different aspects of the Tac-Toe, this calculation can be performed using the game: King safety, development, defending own men, minimax algorithm. Shannon was really the first to attacking opponent’s men, and so on (Newell et al., argue that the minimax algorithm as it was originally 1958). proposed was unsuitable for chess agents – the This is similar to how humans seem to play chess, branching factor is much too high and the games are far which perhaps explains why this selectivity doesn’t too long to calculate every possible combination. adversely affect the agent’s ability to play by much, Shannon suggested that a chess agent would have to despite the radical savings it affords. For every 300 stop branching at some arbitrary point and evaluate the boards the Los Alamos program evaluates, Bernstein’s current board based on some heuristic. program considers only one board, and they both go to However, Shannon did not devise an actual chess a depth of four ply. agent. This was left up to Alan Turing, who in 1953 In spite of this massive reduction of complexity, and published an article detailing the inner working of a in spite of the faster hardware available under which chess agent as Shannon had envisioned it. Alan Turing this Bernstein’s program was run, it played at a rate did not create a program – he created a model or a comparable to the Los Alamos agent: Bernstein tended scheme through which he could simulate a chess agent to make a move in eight minutes, which is close to the by hand. Consequently, Turing’s agent required very Los Alamos program’s move time (ten minutes). This little computational power, but it did not play chess effect can be attributed to the fact that Bernstein’s very well, and manual simulation was prone to mistakes program performed an extensive analysis on each board (Turing made an error in his simulation, resulting in a it considered, whereas the Los Alamos program hardly different move than the actual agent would have taken, looked at all the boards it was evaluating. Part of this in the very same paper where he presented this idea). In extensive analysis was Bernstein’s evaluation function spite of all this, chess agents had begun to take on (which was much more sophisticated than the Los human proportions: Turing’s agent could play just as Alamos program’s evaluation function) and another well (or just as badly) as a beginning chess player, so part of this analysis was devoted to allowing the perhaps it was fitting that it was one of the first. plausible move generators to generate good moves. One of the first computer programs that played chess automatically was invented at Los Alamos in 1956. 3.1 Greenblatt and a Second Generation of Agents Running on the MANIAC I machine, this agent could There were many chess agents created after Los play chess on a six by six board, by removing the Alamos and Bernstein, but none were truly innovative bishops. It also eliminated special moves , reducing the or particularly good at playing chess until 1966 when complexity of the problem to a size manageable for the an undergraduate student at MIT, Richard Greenblatt, technology of the time. The Los Alamos agent worked impressed everyone in the field with his chess program, truly as Claude Shannon had envisioned: it explored MAC HACK IV. This was the first agent to win against every possibility to a depth of four ply (two moves for a professional chess player in an official competition. Black and two moves for White), evaluating these The Greenblatt program is fairly intricate, compared boards in terms of the material possessed by both sides, to the other agents mentioned above. One of the and by how much mobility each position afforded to the cornerstones for Greenblatt’s strategy involved pieces. These values were crystallized into a decision providing the agent with chess specific information and by following the minimax algorithm up through the with chess lore. Many of its move generators were only tree. triggered in specific situations, such as when the king is The Los Alamos agent was reasonably efficient, in danger. A pre-compiled list of starting moves taking roughly ten minutes to calculate a single move.