Move ordering refers to the practice of selecting the most promising moves first during game-tree search (especially in computer chess).12 In minimax searches with alpha–beta pruning, good move ordering is important, examining stronger moves early causes cutoffs that eliminate subtrees, vastly reducing the number of nodes searched. In the ideal case of perfect move ordering the search complexity drops from to approximately , effectively halving the effective branching factor to and allowing roughly twice the search depth for a given computational effort.3 Claude Shannon observed that although a typical chess position may have on the order of 30 legal moves, effective pruning and heuristics reduce the useful branching factor to only a few.4
History
The idea of ordering moves came before computers. In his 1950 seminal paper "Programming a Computer for Playing Chess",5 Claude Shannon noted the enormous size of the full game tree (estimated at nodes) and suggested that a simple evaluation coupled with search all variations to a fixed depth would be impractical. Shannon saw that any chess program would need to focus on selected moves and prune aggressively to be useful. The formal alpha–beta algorithm appeared in the late 1950s and 1960s as a way to prune branches without changing the minimax result. Early on, it was noted that alpha–beta's pruning power depends entirely on the order in which moves are examined. In 1963, Alexander Brudno independently described alpha–beta-like search and noted that best-case node counts occur when moves are tried in the right order; by the 1970s researchers such as Donald Knuth and Ronald Moore had mathematically analyzed alpha–beta and shown that under perfect ordering its time is .6
In the 1970s and 1980s the major practical heuristics for move ordering were introduced. The use of iterative deepening was rediscovered in chess programs and found to significantly improve move ordering for deeper searches. The idea was to use the best move found at shallow depth as the first move in the next deeper search.7 Transposition tables (Mac Hack by Richard Greenblatt in 1966 first used a hash) allowed the program to store the best move for each position and reuse it as the first choice on subsequent visits.8 In 1968 Barbara Liskov and others independently suggested storing moves that caused beta cutoffs. This eventually became known as the killer heuristic. In 1983 Jonathan Schaeffer proposed the history heuristic. Schaeffer showed that the history scores outperformed simpler heuristics.
Theoretical background
The efficiency of a chess engine's search is almost entirely dependent on its ability to ignore "bad" moves as quickly as possible. Theoretically, if an engine could always examine the best move first, the search space would effectively be reduced to its square root.1 This is achieved through a combination of game theory and heuristic-based pruning.9
A pure minimax game-tree search explores all moves to a fixed depth, which is exponentially expensive.10 Alpha–beta pruning improves this by carrying two bounds which are Alpha (α) and Beta (β).11 Alpha is the minimum score the maximizing player is assured of, and Beta is the maximum score the minimizing player can permit. Whenever a node's value cannot possibly influence the final decision because it is worse than a previously examined move, the branch is cut off. This has a probability to have the same result as full minimax but with fewer nodes.
Iterative deepening depth-first search is commonly used. The engine repeatedly searches with increasing depth limits, using the best move from depth as the first move to try at depth .12 This almost produces a strong initial bound (alpha or beta) on the first move, which narrows the window for the rest of the search. Iterative deepening converts a depth-first search into something akin to a best-first search by leveraging past results. When a transposition table contains an entry for the current position, its stored best move is tried first.13 After a transposition move is considered, typical ordering heuristics prioritize captures and checks, since forcing tactical moves often lead to large advantages or immediate cut offs.14
Engines sort capture moves by the Most Valuable Victim–Least Valuable Aggressor (MVV-LVA) heuristic.8 To avoid obviously losing trades, a static exchange evaluation (SEE) is often applied to prune captures that reduce material balance. If the forcing moves do not produce a cutoff, the engine then tries its stored killer moves, which are tried at early depth. If a non-killer move causes a cutoff, it becomes a new killer. Finally, any remaining quiet moves are ordered by their history heuristic scores, which accumulate bonuses when a move causes a cutoff.15 Each time a move causes a cutoff anywhere in the search, its history score increases. Thus moves that have historically caused cutoffs rank higher in future ordering.
Advanced topics
Researchers have developed several refinements beyond the basic schemes. Countermove heuristic assumes that many moves have a "natural" response, irrespective of the actual position.16 Other miscellaneous techniques such as "Butterfly boards"17 and "last-best-reply" heuristics are related ideas that exploit local search history. Some engines use machine learning, early work by Kocsis et al. and Greer applied neural networks to predict move values or ordering. Most strong engines still rely on the simple set of PV moves, hash moves, MVV-LVA capture sorting, killer and history tables.
See also
See also
References
References
- Russell, Stuart; Norvig, Peter (April 28, 2020). Artificial Intelligence: A Modern Approach (4th ed.). Hoboken, New Jersey: Pearson Education. pp. 152–161. ISBN 978-0134610993.
- Schaeffer, Jonathan; Plaat, Aske (February 20, 1996). New Advances in Alpha-Beta Searching. CSC '96: Proceedings of the 1996 ACM 24th Annual Conference on Computer Science. Philadelphia, Pennsylvania: Association for Computing Machinery. pp. 124–130. doi:10.1145/228329.228344. ISBN 0-89791-828-2.
- Reinefeld, Alexander; Marsland, T. Anthony (July 31, 1994). "Enhanced Iterative-Deepening Search". IEEE Transactions on Pattern Analysis and Machine Intelligence. 16 (7). IEEE: 701–710. Bibcode:1994ITPAM..16..701R. doi:10.1109/34.297950. eISSN 1939-3539. ISSN 0162-8828. Full text available at ResearchGate (deprecated than the original)
- Shannon, Claude E. (March 1950). "Programming a Computer for Playing Chess" (PDF). Philosophical Magazine. Ser. 7. 41 (314). Taylor & Francis: 256–275. doi:10.1080/14786445008521796.
- Shannon 1950, pp. 257–268.
- Marsland, T. Anthony (March 1, 1986). "A Review of Game-Tree Pruning". ICGA Journal. 9 (1): 3–19. doi:10.3233/ICG-1986-9102. eISSN 2468-2438. ISSN 1389-6911 – via Sage Journals.
- Knuth, Donald; Moore, Ronald (December 1, 1975). "An Analysis of Alpha-Beta Pruning". Artificial Intelligence. 6 (4). Elsevier: 293–326. doi:10.1016/0004-3702(75)90019-3. ISSN 0004-3702 – via ScienceDirect.
- Greenblatt, Richard (January 1, 1988). "The Greenblatt Chess Program". Computer Chess Compendium. New York: Springer Nature. pp. 56–66. doi:10.1007/978-1-4757-1968-0_7. ISBN 978-1-4757-1970-3.
- Campbell, Murray; Hoane Jr., A. Joseph; Hsu, Feng-hsiung (January 24, 2002). "Deep Blue". Artificial Intelligence. 134 (1–2): 57–83. doi:10.1016/S0004-3702(01)00129-1. ISSN 0004-3702 – via ScienceDirect.
- Cormen, Thomas; Leiserson, Charles; Rivest, Ronald; Stein, Clifford (April 5, 2022). Introduction to Algorithms (4th ed.). MIT Press. pp. 1020–1032. ISBN 978-0-262-04630-5. LCCN 2021037260. OL 34192801M.
- Luger, George (February 26, 2008). Artificial Intelligence: Structures and Strategies for Complex Problem Solving (6th ed.). Addison-Wesley. pp. 161–171. ISBN 978-0321545893. LCCN 2007050376. OCLC 439520815. OL 3946606M.
- Russell, Stuart; Norvig, Peter (December 1, 2009). Artificial Intelligence: A Modern Approach (3rd ed.). Prentice Hall. ISBN 978-0136042594. LCCN 2011-288031. OCLC 359890490.
- Silver, David; Hubert, Thomas; Schrittwieser, Julian; Antonoglou, Ioannis; Lai, Matthew; Guez, Arthur; Lanctot, Marc; Sifre, Laurent; Kumaran, Dharshan; Graepel, Thore; Lillicrap, Timothy; Simonyan, Karen; Hassabis, Demis (December 5, 2017). "Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm". p. 10. arXiv:1712.01815v1 [cs.AI]. "A transposition table faciliates the reuse of values and move orders when the same position is reached by multiple paths."
- Levy, David; Newborn, Monty (1991). How Computers Play Chess (1st ed.). New York: Computer Science Press. pp. 144–148. ISBN 0-7167-8239-1. LCCN 90039244. OCLC 826075762.
- Schaeffer, Jonathan (November 30, 1989). "The History Heuristic and the Performance of Alpha-Beta Enhancements". IEEE Transactions on Pattern Analysis and Machine Intelligence. 11 (11): 1203–1212. doi:10.1109/34.42858. eISSN 1939-3539. ISSN 0162-8828. OCLC 8557794501.
- Uiterwijk, Jos (March 1, 1992). "The Countermove Heuristic". ICGA Journal. 15 (1): 8–15. doi:10.3233/ICG-1992-15103. ISSN 1389-6911. OCLC 10597453955 – via Sage Publishing. "The technique is based on the assumption that many moves have a 'natural' response, irrespective of the actual position in which the moves occur."
- Hartmann, Dap (September 1, 1988). "The Butterfly Heuristic". ICGA Journal. 11 (2–3): 64–71. doi:10.3233/ICG-1988-112-303. ISSN 1389-6911 – via Sage Publishing.