Share to: share facebook share twitter share wa share telegram print page

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:

Hari Orang Muda Sedunia 1993Tanggal10 Agustus 1993 (1993-08-10) – 15 Agustus 1993 (1993-08-15)LokasiDenver, Colorado, Amerika SerikatKoordinat39°45′43″N 104°52′52″W / 39.761850°N 104.881105°W / 39.761850; -104.881105Koordinat: 39°45′43″N 104°52′52″W / 39.761850°N 104.881105°W / 39.761850; -104.881105JenisFestival pemudaTemaI came that they might have life, and have it to the full (Yohanes 10:10)PenyelenggaraGerej…

Baron du Saint-Empire Armoiries d'un baron du Saint-Empire Couronne de baron du Saint-Empire Titulature Votre Excellence Création xve siècle Transmission Héréditaire ou personnel Assis sur Baronnie ou nom de famille Type Titre de la petite noblesse d'empire immédiate Abrogation 1806 modifier  Un baron du Saint-Empire (en allemand : Reichsfreiherr) littéralement « seigneur libre » au sens d'affranchi et propriétaire d'une terre — est un ancien titre de noblesse…

العلاقات العمانية السنغافورية سلطنة عمان سنغافورة   سلطنة عمان   سنغافورة تعديل مصدري - تعديل   العلاقات العمانية السنغافورية هي العلاقات الثنائية التي تجمع بين سلطنة عمان وسنغافورة.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدو…

PemberitahuanTemplat ini mendeteksi bahwa artikel bahasa ini masih belum dinilai kualitasnya oleh ProyekWiki Bahasa dan ProyekWiki terkait dengan subjek. Terjadi [[false positive]]? Silakan laporkan kesalahan ini. 14.00, Selasa, 9 April, 2024 (UTC) • hapus singgahan Sebanyak 1.304 artikel belum dinilai Artikel ini belum dinilai oleh ProyekWiki Bahasa Cari artikel bahasa  Cari berdasarkan kode ISO 639 (Uji coba)  Kolom pencarian ini hanya didukung oleh beberapa antarmuka Halaman …

Sub-district in Al Bayda, YemenAl Ghanim آل غنيمSub-districtCountry YemenGovernorateAl BaydaDistrictAsh SharyahPopulation (2004) • Total33,873Time zoneUTC+3 Al Ghanim (Arabic: آل غنيم) is a sub-district located in Ash Sharyah District, Al Bayda Governorate, Yemen. Al Ghanim had a population of 33873 according to the 2004 census.[1][2][3] References ^ الدليل الشامل - محافظة البيضاء- مديرية الشرية-عزل…

Murders in the Rue MorguePoster rilis teatrikal karya Karoly Grosz[1]SutradaraRobert FloreyProduserCarl Laemmle Jr.Skenario Tom Reed Dale Van Every[2] BerdasarkanThe Murders in the Rue Morgueoleh Edgar Allan PoePemeran Bela Lugosi Sidney Fox Leon Ames Bert Roach Brandon Hurst Noble Johnson D'Arcy Corrigan SinematograferKarl W. Freund[2]PenyuntingMilton Carruth[2]PerusahaanproduksiUniversal PicturesDistributorUniversal PicturesTanggal rilis 10 Februari 1932 (1…

Cet article est une ébauche concernant la Nouvelle-Écosse et le libéralisme. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Parti libéral de la Nouvelle-Écosse(en) Nova Scotia Liberal Party Logotype officiel. Présentation Chef Iain Rankin Fondation 1883 Siège 5151 George StreetSuite 1400Halifax (Nouvelle-Écosse)B3J 2T3 Niveau Provincial Président John Gillis Positionnement Centre gauche Idéologie Libéral…

Carlo Osellame Osellame al Cagliari nel 1979 Nazionalità  Italia Altezza 177 cm Peso 71 kg Calcio Ruolo Allenatore (ex centrocampista) Termine carriera 1988 - giocatore Carriera Giovanili 1965-1969 Montebelluna Squadre di club1 1969-1971 Montebelluna1+ (?)[1]1971-1973 Treviso63 (5)1973-1974 Pro Vasto16 (0)1974-1976 Treviso70 (20)1976-1979 Palermo90 (12)1979-1982 Cagliari75 (5)1982 Atalanta6 (0)1982-1984 Modena57 (2)1984-1987 Montebe…

Aulus GabiniusKoin yang dikeluarkan di bawah kekuasaan Gabinius di SiriaKonsul Republik RomawiBerkuasa58 SMPendahuluJulius CaesarPenerusPublius Cornelius Lentulus SpintherGubernur Siria RomawiPendahuluGnaeus Cornelius Lentulus MarcellinusPenerusMarcus Licinius CrassusPendahuluMarcus Calpurnius BibulusPenerusQuintus Caecilius Metellus Nepos IuniorInformasi pribadiKelahiranTidak diketahuiKematians. 47 SMSalona, DalmatiaAgamaPoliteisme Aulus Gabinius (?-48 atau 47 SM) adalah seorang negarawan, jend…

Hong Kong government department Food and Environmental Hygiene Department食物環境衞生署Agency overviewFormed1 January 2000; 24 years ago (2000-01-01)Preceding agenciesUrban CouncilRegional CouncilHeadquarters44/F Queensway Government Offices, 66 Queensway, Hong KongEmployees11,153 (March 2014)[1]Annual budgetHK$5,667,200,000 (2014-15 estimate)[1]Agency executiveIrene Young, Director of Food and Environmental HygieneParent agencyEnvironment and Ecology Bur…

History of medical research Part of a series on theCOVID-19 pandemicScientifically accurate atomic model of the external structure of SARS-CoV-2. Each ball is an atom. COVID-19 (disease) SARS-CoV-2 (virus) Cases Deaths Timeline 2019 2020 January responses February responses March responses April responses May responses June responses July responses August responses September responses October responses November responses December responses 2021 January responses February responses March response…

Association football women's club in Tunisia Football clubAS Banque de l'HabitatFull nameAS Banque de l'HabitatNickname(s)Banque de l'HabitatFounded2005 (19 years ago) (2005)Ground TunisiaOwnerBH Bank (Tunisia) formerly Banque de l'habitatPresident Noureddine RaddadiHead Coach ALi JribiLeagueTunisian Women's Championship2022–23— Home colours Away colours AS Banque de l'Habitat (Arabic: الجمعية الرياضية لبنك الإسكان, lit. 'Association spo…

Liechtenstein Uniformi di gara Casa Trasferta Sport Calcio Federazione LFVLiechtensteiner Fussballverband Confederazione UEFA Codice FIFA LIE Soprannome Nati Selezionatore Konrad Fünfstück Record presenze Peter Jehle (132) Capocannoniere Mario Frick (16) Ranking FIFA 200º (26 ottobre 2023)[1] Sponsor tecnico Errea Esordio internazionale Liechtenstein 0 - 1 SvizzeraBalzers, Liechtenstein; 9 marzo 1982 Migliore vittoria Lussemburgo 0 - 4 Liechtenstein Lussemburgo, Lussemburgo; 13 ottobr…

Akmal TaherLahir27 Juli 1955 (umur 68)Jakarta, IndonesiaKebangsaanIndonesiaPekerjaan- Dirut RSCM, Jakarta- Ketua Ikatan Ahli Urologi Indonesia.Orang tuaTaher dan Rosnalia Akmal Taher (lahir 27 Juli 1955) adalah seorang dokter ahli bedah asal Indonesia. Ia pernah menjabat sebagai direktur utama Rumah Sakit Dr. Cipto Mangunkusumo, Jakarta dan Ketua Ikatan Ahli Urologi Indonesia. Akmal merupakan pemilik hak paten use of inhibitor of phosphodiesterase IV di Jerman, Amerika Serikat, Kanada, dan …

Castle in Hamadan Province, Iran Saheb Ekhtiarieh castleقلعه صاحب اختیاریهGeneral informationTypeCastleTown or cityAsadabad CountyCountry IranSaheb Ekhtiarieh castle (Persian: قلعه صاحب اختیاریه) is a historical castle located in Asadabad County in Hamadan Province, The longevity of this fortress dates back to the Qajar dynasty.[1][2] References ^ Encyclopaedia of the Iranian Architectural History. Cultural Heritage, Handicrafts and Tourism Organiz…

Dandie Dinmont redirects here. For the fictional character, see Guy Mannering. Dog breedDandie Dinmont TerrierThe mustard colour of the Dandie can be any shade including and between reddish brown and fawn.Common nicknamesDandieHindlee TerrierOriginScotlandTraitsHeight 8–11 inches (20–28 cm)Weight 18–24 pounds (8.2–10.9 kg)Coat Rough coatedColour Pepper or mustardLife span 11–13 yearsKennel club standardsThe Kennel Club standardFédération Cynologique Internationale …

American football player and coach (1930–2020) American football player Don ShulaShula in 1987No. 96, 44, 25, 26Position:Defensive backPersonal informationBorn:(1930-01-04)January 4, 1930Grand River, Ohio, U.S.Died:May 4, 2020(2020-05-04) (aged 90)Indian Creek, Florida, U.S.Height:5 ft 11 in (1.80 m)Weight:190 lb (86 kg)Career informationHigh school:Harvey (Painesville, Ohio)College:John CarrollNFL draft:1951 / Round: 9 / Pick: 110Career histor…

此条目序言章节没有充分总结全文内容要点。 (2019年3月21日)请考虑扩充序言,清晰概述条目所有重點。请在条目的讨论页讨论此问题。 哈萨克斯坦總統哈薩克總統旗現任Қасым-Жомарт Кемелұлы Тоқаев卡瑟姆若马尔特·托卡耶夫自2019年3月20日在任任期7年首任努尔苏丹·纳扎尔巴耶夫设立1990年4月24日(哈薩克蘇維埃社會主義共和國總統) 哈萨克斯坦 哈萨克斯坦政府與…

本條目存在以下問題,請協助改善本條目或在討論頁針對議題發表看法。 此條目需要編修,以確保文法、用詞、语气、格式、標點等使用恰当。 (2013年8月6日)請按照校對指引,幫助编辑這個條目。(幫助、討論) 此條目剧情、虛構用語或人物介紹过长过细,需清理无关故事主轴的细节、用語和角色介紹。 (2020年10月6日)劇情、用語和人物介紹都只是用於了解故事主軸,輔助讀…

Kuil untuk Juturna, dibangun oleh Catulus untuk merayakan kemenangannya dalam Pertempuran Kepulauan Aegates di Largo di Torre Argentina, Roma. Gaius Lutatius Catulus (Latin: C·LVTATIVS·C·F·CATVLVS) adalah seorang negarawan Romawi yang diangkat sebagai konsul Romawi pada tahun 242 SM. Ia dikenal akan kiprahnya sebagai komandan angkatan laut saat meletusnya Perang Punik I melawan Kartago.[1] Ia memimpin armada Romawi dalam Pertempuran Kepulauan Aegates pada 10 Maret 241 SM dan berhasil…

Kembali kehalaman sebelumnya