Alpha–beta pruning

Alpha–beta pruning
ClassSearch algorithm
Worst-case performance
Best-case performance

Alpha–beta pruning is a search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm in its search tree. It is an adversarial search algorithm used commonly for machine playing of two-player combinatorial games (Tic-tac-toe, Chess, Connect 4, etc.). It stops evaluating a move when at least one possibility has been found that proves the move to be worse than a previously examined move. Such moves need not be evaluated further. When applied to a standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision.[1]

History

John McCarthy during the Dartmouth Workshop met Alex Bernstein of IBM, who was writing a chess program. McCarthy invented alpha–beta search and recommended it to him, but Bernstein was "unconvinced".[2]

Allen Newell and Herbert A. Simon who used what John McCarthy calls an "approximation"[3] in 1958 wrote that alpha–beta "appears to have been reinvented a number of times".[4] Arthur Samuel had an early version for a checkers simulation. Richards, Timothy Hart, Michael Levin and/or Daniel Edwards also invented alpha–beta independently in the United States.[5] McCarthy proposed similar ideas during the Dartmouth workshop in 1956 and suggested it to a group of his students including Alan Kotok at MIT in 1961.[6] Alexander Brudno independently conceived the alpha–beta algorithm, publishing his results in 1963.[7] Donald Knuth and Ronald W. Moore refined the algorithm in 1975.[8][9] Judea Pearl proved its optimality in terms of the expected running time for trees with randomly assigned leaf values in two papers.[10][11] The optimality of the randomized version of alpha–beta was shown by Michael Saks and Avi Wigderson in 1986.[12]

Core idea

A game tree can represent many two-player zero-sum games, such as chess, checkers, and reversi. Each node in the tree represents a possible situation in the game. Each terminal node (outcome) of a branch is assigned a numeric score that determines the value of the outcome to the player with the next move.[13]

The algorithm maintains two values, alpha and beta, which respectively represent the minimum score that the maximizing player is assured of and the maximum score that the minimizing player is assured of. Initially, alpha is negative infinity and beta is positive infinity, i.e. both players start with their worst possible score. Whenever the maximum score that the minimizing player (i.e. the "beta" player) is assured of becomes less than the minimum score that the maximizing player (i.e., the "alpha" player) is assured of (i.e. beta < alpha), the maximizing player need not consider further descendants of this node, as they will never be reached in the actual play.

To illustrate this with a real-life example, suppose somebody is playing chess, and it is their turn. Move "A" will improve the player's position. The player continues to look for moves to make sure a better one hasn't been missed. Move "B" is also a good move, but the player then realizes that it will allow the opponent to force checkmate in two moves. Thus, other outcomes from playing move B no longer need to be considered since the opponent can force a win. The maximum score that the opponent could force after move "B" is negative infinity: a loss for the player. This is less than the minimum position that was previously found; move "A" does not result in a forced loss in two moves.

Improvements over naive minimax

An illustration of alpha–beta pruning. The grayed-out subtrees don't need to be explored (when moves are evaluated from left to right), since it is known that the group of subtrees as a whole yields the value of an equivalent subtree or worse, and as such cannot influence the final result. The max and min levels represent the turn of the player and the adversary, respectively.

The benefit of alpha–beta pruning lies in the fact that branches of the search tree can be eliminated.[13] This way, the search time can be limited to the 'more promising' subtree, and a deeper search can be performed in the same time. Like its predecessor, it belongs to the branch and bound class of algorithms. The optimization reduces the effective depth to slightly more than half that of simple minimax if the nodes are evaluated in an optimal or near optimal order (best choice for side on move ordered first at each node).

With an (average or constant) branching factor of b, and a search depth of d plies, the maximum number of leaf node positions evaluated (when the move ordering is pessimal) is O(bd) – the same as a simple minimax search. If the move ordering for the search is optimal (meaning the best moves are always searched first), the number of leaf node positions evaluated is about O(b×1×b×1×...×b) for odd depth and O(b×1×b×1×...×1) for even depth, or . In the latter case, where the ply of a search is even, the effective branching factor is reduced to its square root, or, equivalently, the search can go twice as deep with the same amount of computation.[14] The explanation of b×1×b×1×... is that all the first player's moves must be studied to find the best one, but for each, only the second player's best move is needed to refute all but the first (and best) first player move—alpha–beta ensures no other second player moves need be considered. When nodes are considered in a random order (i.e., the algorithm randomizes), asymptotically, the expected number of nodes evaluated in uniform trees with binary leaf-values is .[12] For the same trees, when the values are assigned to the leaf values independently of each other and say zero and one are both equally probable, the expected number of nodes evaluated is , which is much smaller than the work done by the randomized algorithm, mentioned above, and is again optimal for such random trees.[10] When the leaf values are chosen independently of each other but from the interval uniformly at random, the expected number of nodes evaluated increases to in the limit,[11] which is again optimal for this kind of random tree. Note that the actual work for "small" values of is better approximated using .[11][10]

A chess program that searches four plies with an average of 36 branches per node evaluates more than one million terminal nodes. An optimal alpha-beta prune would eliminate all but about 2,000 terminal nodes, a reduction of 99.8%.[13]

An animated pedagogical example that attempts to be human-friendly by substituting initial infinite (or arbitrarily large) values for emptiness and by avoiding using the negamax coding simplifications.

Normally during alpha–beta, the subtrees are temporarily dominated by either a first player advantage (when many first player moves are good, and at each search depth the first move checked by the first player is adequate, but all second player responses are required to try to find a refutation), or vice versa. This advantage can switch sides many times during the search if the move ordering is incorrect, each time leading to inefficiency. As the number of positions searched decreases exponentially each move nearer the current position, it is worth spending considerable effort on sorting early moves. An improved sort at any depth will exponentially reduce the total number of positions searched, but sorting all positions at depths near the root node is relatively cheap as there are so few of them. In practice, the move ordering is often determined by the results of earlier, smaller searches, such as through iterative deepening.

Additionally, this algorithm can be trivially modified to return an entire principal variation in addition to the score. Some more aggressive algorithms such as MTD(f) do not easily permit such a modification.

Pseudocode

The pseudo-code for depth limited minimax with alpha–beta pruning is as follows:[15]

Implementations of alpha–beta pruning can often be delineated by whether they are "fail-soft," or "fail-hard". With fail-soft alpha–beta, the alphabeta function may return values (v) that exceed (v < α or v > β) the α and β bounds set by its function call arguments. In comparison, fail-hard alpha–beta limits its function return value into the inclusive range of α and β. The main difference between fail-soft and fail-hard implementations is whether α and β are updated before or after the cutoff check. If they are updated before the check, then they can exceed initial bounds and the algorithm is fail-soft.

The following pseudo-code illustrates the fail-hard variation.[15]

function alphabeta(node, depth, α, β, maximizingPlayer) is
    if depth == 0 or node is terminal then
        return the heuristic value of node
    if maximizingPlayer then
        value := −∞
        for each child of node do
            value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
            if value > β then
                break (* β cutoff *)
            α := max(α, value)
        return value
    else
        value := +∞
        for each child of node do
            value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
            if value < α then
                break (* α cutoff *)
            β := min(β, value)
        return value
(* Initial call *)
alphabeta(origin, depth, −, +, TRUE)

The following pseudocode illustrates fail-soft alpha-beta.

function alphabeta(node, depth, α, β, maximizingPlayer) is
    if depth == 0 or node is terminal then
        return the heuristic value of node
    if maximizingPlayer then
        value := −∞
        for each child of node do
            value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
            α := max(α, value)
            if value ≥ β then
                break (* β cutoff *)
        return value
    else
        value := +∞
        for each child of node do
            value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
            β := min(β, value)
            if value ≤ α then
                break (* α cutoff *)
        return value
(* Initial call *)
alphabeta(origin, depth, −, +, TRUE)

Heuristic improvements

Further improvement can be achieved without sacrificing accuracy by using ordering heuristics to search earlier parts of the tree that are likely to force alpha–beta cutoffs. For example, in chess, moves that capture pieces may be examined before moves that do not, and moves that have scored highly in earlier passes through the game-tree analysis may be evaluated before others. Another common, and very cheap, heuristic is the killer heuristic, where the last move that caused a beta-cutoff at the same tree level in the tree search is always examined first. This idea can also be generalized into a set of refutation tables.

Alpha–beta search can be made even faster by considering only a narrow search window (generally determined by guesswork based on experience). This is known as an aspiration window. In the extreme case, the search is performed with alpha and beta equal; a technique known as zero-window search, null-window search, or scout search. This is particularly useful for win/loss searches near the end of a game where the extra depth gained from the narrow window and a simple win/loss evaluation function may lead to a conclusive result. If an aspiration search fails, it is straightforward to detect whether it failed high (high edge of window was too low) or low (lower edge of window was too high). This gives information about what window values might be useful in a re-search of the position.

Over time, other improvements have been suggested, and indeed the Falphabeta (fail-soft alpha–beta) idea of John Fishburn is nearly universal and is already incorporated above in a slightly modified form. Fishburn also suggested a combination of the killer heuristic and zero-window search under the name Lalphabeta ("last move with minimal window alpha–beta search").

Other algorithms

Since the minimax algorithm and its variants are inherently depth-first, a strategy such as iterative deepening is usually used in conjunction with alpha–beta so that a reasonably good move can be returned even if the algorithm is interrupted before it has finished execution. Another advantage of using iterative deepening is that searches at shallower depths give move-ordering hints, as well as shallow alpha and beta estimates, that both can help produce cutoffs for higher depth searches much earlier than would otherwise be possible.

Algorithms like SSS*, on the other hand, use the best-first strategy. This can potentially make them more time-efficient, but typically at a heavy cost in space-efficiency.[16]

See also

References

  1. ^ Russell & Norvig 2021, p. 152-161.
  2. ^ McCarthy, John (2006-10-30). "The Dartmouth Workshop--as planned and as it happened". www-formal.stanford.edu. Retrieved 2023-10-29.
  3. ^ McCarthy, John (27 November 2006). "Human Level AI Is Harder Than It Seemed in 1955". Stanford University. Retrieved 2006-12-20.
  4. ^ Newell, Allen; Simon, Herbert A. (1 March 1976). "Computer science as empirical inquiry: symbols and search". Communications of the ACM. 19 (3): 113–126. doi:10.1145/360018.360022.
  5. ^ Edwards, D.J.; Hart, T.P. (4 December 1961). The Alpha–beta Heuristic (Technical report). Massachusetts Institute of Technology. hdl:1721.1/6098. AIM-030.
  6. ^ Kotok, Alan (2004) [1962]. "A Chess Playing Program". Artificial Intelligence Project. RLE and MIT Computation Center. Memo 41. Retrieved 2006-07-01.
  7. ^ Marsland, T.A. (May 1987). "Computer Chess Methods" (PDF). In Shapiro, S. (ed.). Encyclopedia of Artificial Intelligence. Wiley. pp. 159–171. ISBN 978-0-471-62974-0. Archived from the original (PDF) on 2008-10-30.
  8. ^ Knuth, Donald E.; Moore, Ronald W. (1975). "An analysis of alpha-beta pruning". Artificial Intelligence. 6 (4): 293–326. doi:10.1016/0004-3702(75)90019-3. S2CID 7894372.
  9. ^ Abramson, Bruce (1 June 1989). "Control strategies for two-player games". ACM Computing Surveys. 21 (2): 137–161. doi:10.1145/66443.66444. S2CID 11526154.
  10. ^ a b c Pearl, Judea (1980). "Asymptotic Properties of Minimax Trees and Game-Searching Procedures". Artificial Intelligence. 14 (2): 113–138. doi:10.1016/0004-3702(80)90037-5.
  11. ^ a b c Pearl, Judea (1982). "The Solution for the Branching Factor of the Alpha-Beta Pruning Algorithm and Its Optimality". Communications of the ACM. 25 (8): 559–64. doi:10.1145/358589.358616. S2CID 8296219.
  12. ^ a b Saks, M.; Wigderson, A. (1986). "Probabilistic Boolean Decision Trees and the Complexity of Evaluating Game Trees". 27th Annual Symposium on Foundations of Computer Science. pp. 29–38. doi:10.1109/SFCS.1986.44. ISBN 0-8186-0740-8. S2CID 6130392.
  13. ^ a b c Levy, David (January 1986). "Alpha-Beta Soup". MacUser. pp. 98–102. Retrieved 2021-10-19.
  14. ^ Russell & Norvig 2021, p. 155.
  15. ^ a b Russell & Norvig 2021, p. 154.
  16. ^ Pearl, Judea; Korf, Richard (1987), "Search techniques", Annual Review of Computer Science, 2: 451–467, doi:10.1146/annurev.cs.02.060187.002315, Like its A* counterpart for single-player games, SSS* is optimal in terms of the average number of nodes examined; but its superior pruning power is more than offset by the substantial storage space and bookkeeping required.

Bibliography

Read other articles:

Overview of Hinduism in Finland Hinduism by country Africa Algeria Angola Benin Botswana Burkina Faso Burundi Cameroon Cape Verde Central African Republic Chad Comoros Democratic Republic of the Congo Republic of the Congo Djibouti Egypt Equatorial Guinea Eritrea Eswatini Ethiopia Gabon Gambia Ghana Guinea Guinea-Bissau Ivory Coast Kenya Lesotho Liberia Libya Madagascar Malawi Mali Mauritania Mauritius Morocco Western Sahara Mozambique Namibia Niger Nigeria Rwanda São Tomé and Príncipe Sen...

 

المغربي التبريزي معلومات شخصية مكان الميلاد تبريز مواطنة إيران  الحياة العملية المهنة شاعر  اللغات الفارسية  تعديل مصدري - تعديل     هذه المقالة عن المغربي التبريزي. لمعانٍ أخرى، طالع التبريزي. المغربي التبريزي (749 - نحو 809 هـ) هو شاعر فرسي. هو شمس الدين محمد بن ع

 

Totò, Peppino e la... malafemminaTotò e Peppino nella celebre scena della dettatura della letteraPaese di produzioneItalia Anno1956 Durata102 min Dati tecniciB/Nrapporto: 1,20:1 Generecommedia, comico RegiaCamillo Mastrocinque SoggettoNicola Manzari SceneggiaturaSandro Continenza, Nicola Manzari, Edoardo Anton, Francesco Thellung ProduttoreIsidoro Broggi, Renato Libassi Casa di produzioneD.D.L. Distribuzione in italianoCineriz FotografiaMario Albertelli, Claudio Cirillo MontaggioGisa Ra...

Southern Chinese tea-based beverage This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Lei cha – news · newspapers · books · scholar · JSTOR (August 2021) (Learn how and when to remove this template message) Hakka lei cha Lei chaTraditional Chinese擂茶Simplified Chinese擂茶TranscriptionsStandard Mandar...

 

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Desember 2022. Niphargobates Status konservasi Rentan (IUCN 2.3) Klasifikasi ilmiah Kerajaan: Animalia Filum: Arthropoda Subfilum: Krustasea Kelas: Malacostraca Ordo: Amphipoda Famili: Niphargidae Genus: NiphargobatesSket, 1981 Spesies Niphargobates lefkodemona...

 

Medical conditionBone metastasis3D rendered CT scan of bone metastases of the hip bone, in a 60 year old woman with parotid gland cancer. Large lesions are seen on the ilium on the more distant side. Involvement of the vertebral column has caused a compression fracture.SpecialtyOncology Bone metastasis, or osseous metastatic disease, is a category of cancer metastases that result from primary tumor invasions into bones. Bone-originating primary tumors such as osteosarcoma, chondrosarcoma, and...

Novel by Richard Condon The Vertical Smile First editionAuthorRichard CondonCountryUnited StatesLanguageEnglishGenrePolitical SatirePublisherNew York, Dial PressPublication date1971Media typePrint (Hardback, Paperback)Pages334 pp (first edition, hardback)ISBN978-0803796133OCLC195069 The Vertical Smile is a political satire novel by Richard Condon, published in 1971. It deals with politics, sex and greed, centering on the 68-year-old mother of a political candidate falling in love with a ...

 

المقالات في هذا التصنيف يجب نقلها إلى التصنيفات الفرعية عندما لا تكون مقالات أساسية. يحتاج هذا التصنيف لمتابعة دائمة لتجنب امتلائه بعدد كبير من المقالات. يستحسن أن يحتوي هذا التصنيف على تصنيفات فرعية فقط. البرامج التلفزيونيَّة التي تقع أحداثها في الولايات المُتحدة الأمري...

 

1964 United States Senate election in Washington ← 1958 November 3, 1964 1970 →   Nominee Henry M. Jackson Lloyd J. Andrews Party Democratic Republican Popular vote 875,950 337,138 Percentage 72.21% 27.79% County resultsJackson:      50–60%      60–70%      70–80%      80–90% U.S. senator before election Henry M. Jackson Democratic Elected U.S. Senator He...

Bagian dari seri tentangNazisme Organisasi Nationalsozialistischer Reichsbund für Leibesübungen (NSRL) Partai Pekerja Jerman Sosialis Nasional (NSDAP) Geheime Staatspolizei (Gestapo) Sturmabteilung (SA) Schutzstaffel (SS) Pemuda Hitler (HJ) Liga Perempuan Jerman (BDM) Liga Wanita Sosialis Nasional (NSF) Sejarah Garis waktu awal Kenaikan Hitler Machtergreifung Persenjataan Jerman Jerman Nazi Agama di Jerman Nazi Malam Pisau-Pisau Panjang Rapat Nuremberg Pakta Anti-Komintern Kristallnacht Per...

 

American billionaire and businesswoman Abigail JohnsonJohnson in 2012BornAbigail Pierrepont Johnson (1961-12-19) December 19, 1961 (age 61)Boston, Massachusetts, USEducationWilliam Smith College (BA)Harvard University (MBA)OccupationBusinesswomanTitleChairwoman, CEO, and president, Fidelity InvestmentsChairwoman, Fidelity InternationalSpouse Christopher McKown ​ ​(m. 1988)​Children2ParentEdward Johnson III (father)RelativesEdward C. Johnson II (grandfat...

 

Halaman ini berisi artikel tentang pemilihan umum presiden Amerika Serikat 2016. Untuk pemilu lain di Amerika Serikat pada hari yang sama, lihat pemilihan umum Amerika Serikat 2016. Pemilihan umum presiden Amerika Serikat 2016201220208 November 2016538 anggota Electoral College270 elektoral untuk menangKehadiran pemilih55,7%[1] (estimated) 0,4 ppKandidat   Calon Donald Trump Hillary Clinton Partai Republik Demokrat Negara bagian New York New York Pendamping Mike Pence Tim Ka...

Overview of smoking in GreeceRoyal decree of 1856, introducing the first ban on smoking in modern Greece. Prohibition was valid only within state buildings and was grounded on the need to prevent accidents. Smoking in Greece was at the highest rate of tobacco consumption (more than 40%) in the European Union in 2010.[1] In 2014, Greece had the highest rate of smoking in the European Union.[2] According to a survey published by the European Commission Day for World No Tobacco D...

 

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Supertoon – news · newspapers · books · scholar · JSTOR (November 2011) (Learn how and when to remove this template message) ...

 

Den här artikeln har skapats av Lsjbot, ett program (en robot) för automatisk redigering. (2015-12)Artikeln kan innehålla fakta- eller språkfel, eller ett märkligt urval av fakta, källor eller bilder. Mallen kan avlägsnas efter en kontroll av innehållet (vidare information) Christmas Creek Mine Gruva Land  Australien Delstat Western Australia Kommun East Pilbara Höjdläge 476 m ö.h. Koordinater 22°23′46″S 119°43′28″Ö / 22.39611°S 119.72454...

Jury Nullification: The Evolution of a Doctrine AuthorClay ConradCountryUnited StatesLanguageEnglishSubjectJury nullificationPublished1998, Carolina Academic PressMedia typePrintPages311ISBN0890897026OCLC40622647Dewey Decimal347.7375LC ClassKF8982 Jury Nullification: The Evolution of a Doctrine, by Clay Conrad, is one of the major book-length treatments of jury nullification.[1] The Federal Lawyer noted, Conrad provides...a comprehensive overview of jury nullification in his...

 

Theatrical appearances of fictional animated singing group Alvin and the ChipmunksLogo of the 2007 filmCreated byRoss BagdasarianOriginal workAlvin and the ChipmunksOwnerRoss Bagdasarian(1987–present)Films and televisionFilm(s) The Chipmunk Adventure Alvin and the Chipmunks The Squeakquel Chipwrecked The Road Chip Direct-to-video Meet Frankenstein Meet the Wolfman Little Alvin and the Mini-Munks AudioSoundtrack(s) The Chipmunk Adventure Little Alvin and the mini-Munks Alvin and the Chipmunk...

 

Railway line in Sydney, New South Wales, Australia Airport LinkView of the Airport Line as it runs through Mascot.OverviewOther name(s)Airport Line, New Southern RailwayOwner Transport Asset Holding Entity (tunnel and one station) Airport Link Company (four stations) TerminiCentralWolli CreekStations5ServiceOperator(s) Sydney Trains (trains and one station) Airport Link Company (four stations) Rolling stockK, M, A and B setsHistoryOpened21 May 2000 (2000-05-21)TechnicalLine len...

For the World War I formation, see 7th (Meerut) Division. 7th Infantry DivisionFormation sign for the 7th Indian Infantry Division.[1]Active1940-presentTypeInfantrySizeDivisionGarrison/HQFerozepurNickname(s)Golden Arrow DivisionEngagementsBattle of the Admin BoxBattle of KohimaBattle of Central BurmaIrrawaddy RiverCommandersNotablecommandersFrank MesservyGeoffrey Charles EvansMilitary unit The 7th Infantry Division is a war-formed infantry division, part of the British Indian Army tha...

 

StarCraft 2Wings of LibertyDéveloppeur Blizzard EntertainmentÉditeur Blizzard EntertainmentRéalisateur Dustin BrowderScénariste Andrew ChambersBrian KindreganChris MetzenCompositeur Derek DukeGlenn StaffordNeal AcreeRussell BrowerProducteur Chris SigatyDébut du projet 2003Date de sortie INT : 27 juillet 2010[1] Genre Stratégie en temps réelMode de jeu Un joueur, multijoueurPlate-forme Windows[2], Mac OS X[3]Langue MultilingueMoteur HavokVersion 4.11.3 (17 décembre 2019)Évaluatio...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!