<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=129.78.56.196</id>
	<title>formulasearchengine - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=129.78.56.196"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/wiki/Special:Contributions/129.78.56.196"/>
	<updated>2026-04-10T13:43:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0-wmf.28</generator>
	<entry>
		<id>https://en.formulasearchengine.com/index.php?title=Comb_sort&amp;diff=2469</id>
		<title>Comb sort</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/index.php?title=Comb_sort&amp;diff=2469"/>
		<updated>2013-10-08T03:28:45Z</updated>

		<summary type="html">&lt;p&gt;129.78.56.196: /* C */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{other uses2|Alphabeta}}&lt;br /&gt;
{{Tree search algorithm}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Alpha–beta pruning&#039;&#039;&#039; is a [[search algorithm]] that seeks to decrease the number of nodes that are evaluated by the [[Minimax#Minimax algorithm with alternate moves|minimax algorithm]] in its [[game tree|search tree]]. It is an adversarial search algorithm used commonly for machine playing of two-player games ([[Tic-tac-toe]], [[Chess]], [[Go (board game)|Go]], etc.). It stops completely 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.&amp;lt;ref name=&amp;quot;RN10&amp;quot;&amp;gt;{{Cite book &lt;br /&gt;
| first = Stuart J. &lt;br /&gt;
| last = Russell &lt;br /&gt;
| first2 = Peter &lt;br /&gt;
| last2 = Norvig &lt;br /&gt;
| title = Artificial Intelligence: A Modern Approach &lt;br /&gt;
| url = http://aima.cs.berkeley.edu/ &lt;br /&gt;
| year = 2010 &lt;br /&gt;
| edition = 3rd &lt;br /&gt;
| publisher = Pearson Education, Inc.&lt;br /&gt;
| publication-place = Upper Saddle River, New Jersey&lt;br /&gt;
| isbn = 0-13-604259-7 &lt;br /&gt;
| author-link=Stuart J. Russell &lt;br /&gt;
| author2-link=Peter Norvig&lt;br /&gt;
| page=167 &lt;br /&gt;
| postscript = &amp;lt;!-- Bot inserted parameter. Either remove it; or change its value to &amp;quot;.&amp;quot; for the cite to end in a &amp;quot;.&amp;quot;, as necessary. --&amp;gt;{{inconsistent citations}}&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
[[Allen Newell]] and [[Herbert A. Simon]] who used what [[John McCarthy (computer scientist)|John McCarthy]] calls an &amp;quot;approximation&amp;quot;&amp;lt;ref name=&amp;quot;JMC&amp;quot;&amp;gt;{{cite web&lt;br /&gt;
  | author = McCarthy, John&lt;br /&gt;
  | title = Human Level AI Is Harder Than It Seemed in 1955&lt;br /&gt;
  | date = LaTeX2HTML 27 November 2006&lt;br /&gt;
  | url = http://www-formal.stanford.edu/jmc/slides/wrong/wrong-sli/wrong-sli.html&lt;br /&gt;
  | accessdate = 2006-12-20&lt;br /&gt;
}}&amp;lt;/ref&amp;gt; in 1958 wrote that alpha–beta &amp;quot;appears to have been reinvented a number of times&amp;quot;.&amp;lt;ref name=NS&amp;gt;{{cite journal&lt;br /&gt;
 | author=Newell, Allen and Herbert A. Simon&lt;br /&gt;
 | title=Computer Science as Empirical Inquiry: Symbols and Search&lt;br /&gt;
 | journal=Communications of the ACM&lt;br /&gt;
 | volume=19 |issue= 3&lt;br /&gt;
 |date=March 1976&lt;br /&gt;
 | url=http://archive.computerhistory.org/projects/chess/related_materials/text/2-3.Computer_science_as_empirical_inquiry/2-3.Computer_science_as_empirical_inquiry.newell_simon.1975.ACM.062303007.pdf&lt;br /&gt;
 |format=PDF| accessdate=2006-12-21&lt;br /&gt;
}}&amp;lt;/ref&amp;gt; [[Arthur Samuel]] had an early version and Richards, Hart, Levine and/or Edwards found alpha–beta independently in the [[United States]].&amp;lt;ref name=&amp;quot;AIM30&amp;quot;&amp;gt;{{cite web&lt;br /&gt;
  | author = Edwards, D.J. and Hart, T.P.&lt;br /&gt;
  | title = The Alpha–beta Heuristic (AIM-030)&lt;br /&gt;
  | publisher = Massachusetts Institute of Technology&lt;br /&gt;
  | date = 4 December 1961 to 28 October 1963&lt;br /&gt;
  | url = http://hdl.handle.net/1721.1/6098&lt;br /&gt;
  | accessdate = 2006-12-21&lt;br /&gt;
}}&amp;lt;/ref&amp;gt; McCarthy proposed similar ideas during the [[Dartmouth Conference]] in 1956 and suggested it to a group of his students including [[Alan Kotok]] at MIT in 1961.&amp;lt;ref name=&amp;quot;AIM41&amp;quot;&amp;gt;{{cite web | last=Kotok | first=Alan | title=MIT Artificial Intelligence Memo 41 | date=XHTML 3 December 2004 | url=http://www.kotok.org/AI_Memo_41.html | accessdate=2006-07-01}}&amp;lt;/ref&amp;gt; [[Alexander Brudno]] independently discovered the alpha–beta algorithm, publishing his results in 1963.&amp;lt;ref name=Marsland&amp;gt;{{cite web&lt;br /&gt;
  | author = [http://www.cs.ualberta.ca/~tony/ Marsland, T.A.]&lt;br /&gt;
  | title = Computer Chess Methods (PDF) from Encyclopedia of Artificial Intelligence. S. Shapiro (editor)&lt;br /&gt;
  | publisher = J. Wiley &amp;amp; Sons&lt;br /&gt;
  |date=May 1987&lt;br /&gt;
  | pages = 159–171&lt;br /&gt;
  | url = http://www.cs.ualberta.ca/~tony/OldPapers/encyc.mac.pdf&lt;br /&gt;
  |format=PDF| accessdate = 2006-12-21&lt;br /&gt;
}}&amp;lt;/ref&amp;gt; [[Donald Knuth]] and Ronald W. Moore refined the algorithm in 1975&amp;lt;ref name=Knuth-Moore&amp;gt;* {{cite journal&lt;br /&gt;
  | author = Knuth, D. E., and Moore, R. W.&lt;br /&gt;
  | title = An Analysis of Alpha–Beta Pruning&lt;br /&gt;
  | journal = Artificial Intelligence&lt;br /&gt;
  |volume=6 |issue=4&lt;br /&gt;
  | year = 1975&lt;br /&gt;
  | pages = 293–326&lt;br /&gt;
  | accessdate = &lt;br /&gt;
  | url = http://www.fileserve.com/file/ZgR5t3j/An_Analysis_of_Alpha-Beta_Pruning.pdf&lt;br /&gt;
  | doi = 10.1016/0004-3702(75)90019-3&lt;br /&gt;
}}&lt;br /&gt;
:* Reprinted as Chapter 9 in {{cite book&lt;br /&gt;
 | last = Knuth&lt;br /&gt;
 | first = Donald E.&lt;br /&gt;
 | title = Selected Papers on Analysis of Algorithms&lt;br /&gt;
 | year = 2000&lt;br /&gt;
 | publisher = Stanford, California: Center for the Study of Language and Information - CSLI Lecture Notes, no. 102&lt;br /&gt;
 | url = http://www-cs-faculty.stanford.edu/~knuth/aa.html&lt;br /&gt;
 | isbn = 1-57586-212-3&lt;br /&gt;
 | oclc = 222512366&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=Abramson&amp;gt;{{cite journal&lt;br /&gt;
 | author=Abramson, Bruce&lt;br /&gt;
 | title=Control Strategies for Two-Player Games&lt;br /&gt;
 | journal=ACM Computing Surveys&lt;br /&gt;
 |date=June 1989&lt;br /&gt;
 | url=http://www.theinformationist.com/pdf/constrat.pdf/&lt;br /&gt;
 | accessdate=2008-08-20&lt;br /&gt;
 | doi=10.1145/66443.66444&lt;br /&gt;
 | volume=21&lt;br /&gt;
 | issue=2&lt;br /&gt;
 | pages=137&lt;br /&gt;
}} {{Dead link|date=September 2010|bot=H3llBot}}&amp;lt;/ref&amp;gt; and [[Judea Pearl]] proved its optimality in 1982.&amp;lt;ref&amp;gt;{{cite journal|last=Pearl|first=Judea|title=The Solution for the Branching Factor of the Alpha–beta Pruning Algorithm and its Optimality|journal=Communications of the ACM|date=August 1982|volume=25|issue=8|pages=559–564}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Improvements over naive minimax ==&lt;br /&gt;
[[Image:AB pruning.svg|thumb|400px|An illustration of alpha–beta pruning. The grayed-out subtrees need not be explored (when moves are evaluated from left to right), since we know 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.]]&lt;br /&gt;
The benefit of alpha–beta pruning lies in the fact that branches of the search tree can be eliminated. This way, the search time can be limited to the &#039;more promising&#039; 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).&lt;br /&gt;
&lt;br /&gt;
With an (average or constant) [[branching factor]] of &#039;&#039;b&#039;&#039;, and a search depth of &#039;&#039;d&#039;&#039; [[Ply (game theory)|plies]], the maximum number of leaf node positions evaluated (when the move ordering is [[wiktionary:pessimal|pessimal]]) is [[Big O notation|&#039;&#039;O&#039;&#039;]](&#039;&#039;b&#039;&#039;*&#039;&#039;b&#039;&#039;*...*&#039;&#039;b&#039;&#039;) = &#039;&#039;O&#039;&#039;(&#039;&#039;b&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;d&#039;&#039;&amp;lt;/sup&amp;gt;) – 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 &#039;&#039;O&#039;&#039;(&#039;&#039;b&#039;&#039;*1*&#039;&#039;b&#039;&#039;*1*...*&#039;&#039;b&#039;&#039;) for odd depth and &#039;&#039;O&#039;&#039;(&#039;&#039;b&#039;&#039;*1*&#039;&#039;b&#039;&#039;*1*...*1) for even depth, or &amp;lt;math&amp;gt;O(b^{d/2}) = O(\sqrt{b^d})&amp;lt;/math&amp;gt;. 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.&amp;lt;ref&amp;gt;{{Russell Norvig 2003}}&amp;lt;/ref&amp;gt; The explanation of &#039;&#039;b&#039;&#039;*1*&#039;&#039;b&#039;&#039;*1*... is that all the first player&#039;s moves must be studied to find the best one, but for each, only the best second player&#039;s 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 ordered at random,&lt;br /&gt;
the average number of nodes evaluated is roughly&lt;br /&gt;
&amp;lt;math&amp;gt;O(b^{3d/4})&amp;lt;/math&amp;gt;.&amp;lt;ref name=&amp;quot;JMC&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Minmaxab.gif|thumb|400px|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.]]&lt;br /&gt;
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 depth-first search|iterative deepening]].&lt;br /&gt;
&lt;br /&gt;
The algorithm maintains two values, alpha and beta, which represent the minimum score that the maximizing player is assured of and the maximum score that the minimizing player is assured of respectively. Initially alpha is negative infinity and beta is positive infinity. As the recursion progresses the &amp;quot;window&amp;quot; becomes smaller. When beta becomes less than alpha, it means that the current position cannot be the result of best play by both players and hence need not be explored further.&lt;br /&gt;
&lt;br /&gt;
Additionally, this algorithm can be trivially modified to return an entire [[Variation (game tree)#Principal variation|principal variation]] in addition to the score. Some more aggressive algorithms such as [[MTD(f)]] do not easily permit such a modification.&lt;br /&gt;
&lt;br /&gt;
==Pseudocode==&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;function&#039;&#039;&#039; alphabeta(node, depth, α, β, maximizingPlayer)&lt;br /&gt;
     &#039;&#039;&#039;if&#039;&#039;&#039; depth = 0 &#039;&#039;&#039;or&#039;&#039;&#039; node is a terminal node&lt;br /&gt;
         &#039;&#039;&#039;return&#039;&#039;&#039; the heuristic value of node&lt;br /&gt;
     &#039;&#039;&#039;if&#039;&#039;&#039; maximizingPlayer&lt;br /&gt;
         &#039;&#039;&#039;for each&#039;&#039;&#039; child of node&lt;br /&gt;
             α := max(α, alphabeta(child, depth - 1, α, β, FALSE))&lt;br /&gt;
             &#039;&#039;&#039;if&#039;&#039;&#039; β ≤ α&lt;br /&gt;
                 &#039;&#039;&#039;break&#039;&#039;&#039; &#039;&#039;(* β cut-off *)&#039;&#039;&lt;br /&gt;
         &#039;&#039;&#039;return&#039;&#039;&#039; α&lt;br /&gt;
     &#039;&#039;&#039;else&#039;&#039;&#039;&lt;br /&gt;
         &#039;&#039;&#039;for each&#039;&#039;&#039; child of node&lt;br /&gt;
             β := min(β, alphabeta(child, depth - 1, α, β, TRUE))&lt;br /&gt;
             &#039;&#039;&#039;if&#039;&#039;&#039; β ≤ α&lt;br /&gt;
                 &#039;&#039;&#039;break&#039;&#039;&#039; &#039;&#039;(* α cut-off *)&#039;&#039;&lt;br /&gt;
         &#039;&#039;&#039;return&#039;&#039;&#039; β&lt;br /&gt;
 &#039;&#039;(* Initial call *)&#039;&#039;&lt;br /&gt;
 alphabeta(origin, depth, -[[Infinity|∞]], +[[Infinity|∞]], TRUE)&lt;br /&gt;
&lt;br /&gt;
== Heuristic improvements ==&lt;br /&gt;
Further improvement can be achieved without sacrificing accuracy, by using ordering [[heuristic]]s to search parts of the tree that are likely to force alpha–beta cutoffs early. For example, in chess, moves that take pieces may be examined before moves that do not, or moves that have scored highly in [[Iterative deepening depth-first search|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 level in the tree search is always examined first.  This idea can be generalized into a set of [[refutation table]]s.&lt;br /&gt;
&lt;br /&gt;
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 &#039;&#039;aspiration search&#039;&#039;. In the extreme case, the search is performed with alpha and beta equal; a technique known as &#039;&#039;zero-window search&#039;&#039;, &#039;&#039;null-window search&#039;&#039;, or &#039;&#039;scout search&#039;&#039;. 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 &#039;&#039;high&#039;&#039; (high edge of window was too low) or &#039;&#039;low&#039;&#039; (lower edge of window was too high). This gives information about what window values might be useful in a re-search of the position.&lt;br /&gt;
&lt;br /&gt;
== Other algorithms ==&lt;br /&gt;
More advanced algorithms that are even faster while still being able to compute the exact minimax value are known, such as SCOUT,&amp;lt;ref&amp;gt;Pearl, J., &amp;quot;SCOUT: A Simple Game-Searching Algorithm With Proven Optimal Properties,&amp;quot; &#039;&#039;Proceedings of the First Annual National Conference on Artificial Intelligence,&#039;&#039; Stanford University, August 18–21, 1980, pp. 143-145.&amp;lt;/ref&amp;gt; [[Negascout]] and [[MTD-f]].   &lt;br /&gt;
&lt;br /&gt;
Since the minimax algorithm and its variants are inherently [[depth-first search|depth-first]], a strategy such as [[Iterative deepening depth-first search|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.&lt;br /&gt;
&lt;br /&gt;
Algorithms like [[SSS*]], on the other hand, use the [[best first search|best-first]] strategy.  This can potentially make them more time-efficient, but typically at a heavy cost in space-efficiency.&amp;lt;ref&amp;gt;{{citation|doi=10.1146/annurev.cs.02.060187.002315|title=Search techniques|journal=Annual Review of Computer Science|volume=2|pages=451–467|year=1987|first1=Judea|last1=Pearl|author1-link=Judea Pearl|first2=Richard|last2=Korf|quote=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.}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Pruning (algorithm)]]&lt;br /&gt;
* [[Branch and bound]]&lt;br /&gt;
* [[Minimax]]&lt;br /&gt;
* [[Combinatorial optimization]]&lt;br /&gt;
* [[Negamax]]&lt;br /&gt;
* [[Transposition table]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* {{cite book | author=George T. Heineman, Gary Pollice, and Stanley Selkow | title= Algorithms in a Nutshell | publisher=[[Oreilly Media]] | year=2008 | chapter=Chapter 7: Path Finding in AI | pages = 217–223 | isbn=978-0-596-51624-6 }}&lt;br /&gt;
* [[Judea Pearl]], &#039;&#039;Heuristics&#039;&#039;, Addison-Wesley, 1984&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* http://www.emunix.emich.edu/~evett/AI/AlphaBeta_movie/sld001.htm&lt;br /&gt;
* http://sern.ucalgary.ca/courses/CPSC/533/W99/presentations/L1_5B_McCullough_Melnyk/&lt;br /&gt;
* http://sern.ucalgary.ca/courses/CPSC/533/W99/presentations/L2_5B_Lima_Neitz/search.html&lt;br /&gt;
* http://www.maths.nott.ac.uk/personal/anw/G13GAM/alphabet.html&lt;br /&gt;
* http://chess.verhelst.org/search.html&lt;br /&gt;
* http://www.frayn.net/beowulf/index.html&lt;br /&gt;
* http://hal.inria.fr/docs/00/12/15/16/PDF/RR-6062.pdf&lt;br /&gt;
* [http://ksquared.de/gamevisual/launch.php?agent=2 Minimax (with or without alpha–beta pruning) algorithm visualization - game tree solving (Java Applet), for balance or off-balance trees]&lt;br /&gt;
* [http://homepage.ufp.pt/~jtorres/ensino/ia/alfabeta.html Demonstration/animation of minimax game search algorithm with alpha–beta pruning (using html5, canvas, javascript, css)]&lt;br /&gt;
{{Game theory}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Alpha-Beta Pruning}}&lt;br /&gt;
[[Category:Game artificial intelligence]]&lt;br /&gt;
[[Category:Graph algorithms]]&lt;br /&gt;
[[Category:Optimization algorithms and methods]]&lt;br /&gt;
[[Category:Search algorithms]]&lt;br /&gt;
[[Category:Articles with example pseudocode]]&lt;br /&gt;
&lt;br /&gt;
{{Link GA|de}}&lt;/div&gt;</summary>
		<author><name>129.78.56.196</name></author>
	</entry>
</feed>