Difference between revisions of "History Heuristic"

From Chessprogramming wiki
Jump to: navigation, search
(2^depth is removed due to overflow issues in modern engines)
(capture history)
 
(5 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
'''History Heuristic''',<br/>
 
'''History Heuristic''',<br/>
a dynamic move ordering method based on the number of cutoffs caused by a given move irrespectively from the position in which the move has been made. The Heuristic was invented by [[Jonathan Schaeffer]] in 1983 <ref>[[Jonathan Schaeffer]] ('''1983'''). ''The History Heuristic''. [[ICGA Journal#6_3|ICCA Journal, Vol. 6, No. 3]]</ref> and works as follows: on a [[Beta-Cutoff|cutoff]] we increment a counter in a special table, addressed either by <span style="background-color: #e0e0e0;">[from][to]</span> (the [[Butterfly Boards]]) or by <span style="background-color: #e0e0e0;">[piece][to]</span> <ref>[[Jos Uiterwijk]] ('''1992'''). ''Memory Efficiency in some Heuristics''. [[ICGA Journal#15_2|ICCA Journal, Vol. 15, No. 2]]</ref> . The added value is typically a multiple of <span style="background-color: #e0e0e0;">depth</span> or <span style="background-color: #e0e0e0;">depth * depth</span>, based on the assumption that otherwise moves from the plies near the leaves would have to much impact on the result. Values retrieved from that table are used to order non-capturing moves. This simple heuristics performs usually better than domain-dependent heuristics, though it may be combined with them. For example, in [[Rebel]] only a few non-captures are ordered by history heuristics, then a piece-square approach is used <ref>[https://web.archive.org/web/20070927195511/members.home.nl/matador/chess840.htm#MOVE%20ORDERING Move Ordering in Rebel] by [[Ed Schroder|Ed Schröder]], also available as [https://silo.tips/download/how-rebel-plays-chess-1 pdf]</ref> . In the literature, history heuristic is often presented as depth-independent generalization of the [[Killer Heuristic|killer moves]]. It is also said to reflect long-term plans in a position.
+
a dynamic move ordering method based on the number of cutoffs caused by a given move irrespectively from the position in which the move has been made. The Heuristic was invented by [[Jonathan Schaeffer]] in 1983 <ref>[[Jonathan Schaeffer]] ('''1983'''). ''The History Heuristic''. [[ICGA Journal#6_3|ICCA Journal, Vol. 6, No. 3]]</ref> and works as follows: on a [[Beta-Cutoff|cutoff]] we increment a counter in a special table, addressed either by <span style="background-color: #e0e0e0;">[from][to]</span> (the [[Butterfly Boards]]) or by <span style="background-color: #e0e0e0;">[piece][to]</span> <ref>[[Jos Uiterwijk]] ('''1992'''). ''Memory Efficiency in some Heuristics''. [[ICGA Journal#15_2|ICCA Journal, Vol. 15, No. 2]]</ref> . The added value is typically a multiple of <span style="background-color: #e0e0e0;">depth</span> or <span style="background-color: #e0e0e0;">depth * depth</span>, based on the assumption that otherwise moves from the plies near the leaves would have to much impact on the result. Values retrieved from that table are used to order non-capturing moves. This simple heuristics performs usually better than domain-dependent heuristics, though it may be combined with them. For example, in [[Stockfish]] all quiet moves that are not hash moves are ordered by history, while in [[Rebel]] only a few non-captures are ordered by history heuristics, then a piece-square approach is used <ref>[https://web.archive.org/web/20070927195511/members.home.nl/matador/chess840.htm#MOVE%20ORDERING Move Ordering in Rebel] by [[Ed Schroder|Ed Schröder]], also available as [https://silo.tips/download/how-rebel-plays-chess-1 pdf]</ref> . In the literature, history heuristic is often presented as depth-independent generalization of the [[Killer Heuristic|killer moves]]. It is also said to reflect long-term plans in a position.
 
 
=Random Noise?=
 
However, all of those statements were made at the time when typical search depth was much lower than today. Nowadays some authors say that given enough search depth, history heuristic produces just a [https://en.wikipedia.org/wiki/Pseudorandom_noise random noise] <ref>[http://www.talkchess.com/forum/viewtopic.php?topic_view=threads&p=163477&t=18345 Re: LMR: history or not?] by [[Robert Hyatt]] from [[CCC]], December 13, 2007</ref> , whereas [[Ed Schroder|Ed Schröder]], advocated not taking into account the cutoffs from the last couple of plies.
 
  
 
=Update=  
 
=Update=  
 
This is how the history [[Array|array]] may be updated, if a [[Beta-Cutoff|beta-cutoff]] occurs:
 
This is how the history [[Array|array]] may be updated, if a [[Beta-Cutoff|beta-cutoff]] occurs:
 
<pre>
 
<pre>
  if ( score >= beta ) { // cutoff
+
if ( score >= beta ) { // cutoff
      if ( isNonCapture (move) )
+
  if ( isNonCapture (move) )
        history[side2move][move.from][move.to] += depth*depth; // 1 << depth
+
      history[side2move][move.from][move.to] += depth*depth;
      ...
+
  ...
      return score;
+
  return score;
  }
+
}
 +
</pre>
 +
 
 +
Modern programs use a more sophisticated formula for history updates:
 +
 
 +
<pre>
 +
void update(Piece piece, Square to, int bonus)
 +
{
 +
    int clampedBonus = clamp(bonus, MAX_HISTORY, -MAX_HISTORY);
 +
    history[piece][to] += clampedBonus - history[piece][to] * abs(clampedBonus) / MAX_HISTORY;
 +
}
 
</pre>
 
</pre>
 +
 +
This scales up history updates when a beta cutoff is unexpected, and scales down history updates when a beta cutoff is expected. A beneficial side effect is that this formula also clamps history values from -MAX_HISTORY to MAX_HISTORY, which prevents oversaturated values.
 +
 
<span id="CMHist"></span>
 
<span id="CMHist"></span>
 +
 
=Counter Moves History=  
 
=Counter Moves History=  
 
A combination of the History Heuristic in conjunction with the [[Countermove Heuristic]], proposed by [[Bill Henry]] in March 2015 <ref>[http://www.talkchess.com/forum/viewtopic.php?t=55535 Improving History Tables] by [[Bill Henry]], [[CCC]], March 02, 2015</ref> , as already used by [[Álvaro Begué]] in his [[Checkers]] program 20 years before <ref>[http://www.talkchess.com/forum/viewtopic.php?t=55535&start=2 Re: Improving History Tables] by [[Álvaro Begué]], [[CCC]], March 02, 2015</ref> , was implemented by [[Stockfish]] contributor [[Stefan Geschwentner]] <ref>[https://groups.google.com/d/msg/fishcooking/d8IhZZJSBGc/PrN-8dP26dIJ Followup moves] by [[Stefan Geschwentner]], [[Computer Chess Forums|FishCooking]], January 12, 2014 » [[History Heuristic#CMHist|Counter Moves History]]</ref>, further tuned and improved by the Stockfish community, and released in [[Stockfish|Stockfish 7]] in January 2016, dubbed '''Counter Moves History''' and mentioned to gain some Elo points <ref>[http://www.talkchess.com/forum/viewtopic.php?t=58935&start=2 Re: Stockfish 7 progress] by Lucas Braesch, [[CCC]], January 17, 2016</ref>. Stockfish's History and Countermove arrays are piece type and [[Target Square|to-square]] based, not butterfly based. Each entry indexed by a previous move, is a complete history table with counters indexed by the move refuting that previous move.  
 
A combination of the History Heuristic in conjunction with the [[Countermove Heuristic]], proposed by [[Bill Henry]] in March 2015 <ref>[http://www.talkchess.com/forum/viewtopic.php?t=55535 Improving History Tables] by [[Bill Henry]], [[CCC]], March 02, 2015</ref> , as already used by [[Álvaro Begué]] in his [[Checkers]] program 20 years before <ref>[http://www.talkchess.com/forum/viewtopic.php?t=55535&start=2 Re: Improving History Tables] by [[Álvaro Begué]], [[CCC]], March 02, 2015</ref> , was implemented by [[Stockfish]] contributor [[Stefan Geschwentner]] <ref>[https://groups.google.com/d/msg/fishcooking/d8IhZZJSBGc/PrN-8dP26dIJ Followup moves] by [[Stefan Geschwentner]], [[Computer Chess Forums|FishCooking]], January 12, 2014 » [[History Heuristic#CMHist|Counter Moves History]]</ref>, further tuned and improved by the Stockfish community, and released in [[Stockfish|Stockfish 7]] in January 2016, dubbed '''Counter Moves History''' and mentioned to gain some Elo points <ref>[http://www.talkchess.com/forum/viewtopic.php?t=58935&start=2 Re: Stockfish 7 progress] by Lucas Braesch, [[CCC]], January 17, 2016</ref>. Stockfish's History and Countermove arrays are piece type and [[Target Square|to-square]] based, not butterfly based. Each entry indexed by a previous move, is a complete history table with counters indexed by the move refuting that previous move.  
Line 27: Line 38:
  
 
'''Continuation History''' is a generalization of [[#Counter Moves History|Counter Moves History]] and Follow Up History. An '''n-ply Continuation History''' is the history score indexed by the move played n-ply ago and the current move. 1-ply and 2-ply continuation histories are most popular and correspond to Counter Moves History and Follow Up History respectively. Many programs, notably [[Stockfish]], also makes use of 3, 4, and 6-ply continuation histories.
 
'''Continuation History''' is a generalization of [[#Counter Moves History|Counter Moves History]] and Follow Up History. An '''n-ply Continuation History''' is the history score indexed by the move played n-ply ago and the current move. 1-ply and 2-ply continuation histories are most popular and correspond to Counter Moves History and Follow Up History respectively. Many programs, notably [[Stockfish]], also makes use of 3, 4, and 6-ply continuation histories.
 +
 +
=Capture History=
 +
 +
'''Capture History''', introduced by [[Stefan Geschwentner]] in 2016, is a variation on history heuristic applied on capture moves. It is a history table indexed by moved piece, target square, and captured piece type. The history table receives a bonus for captures that failed high, and maluses for all capture moves that did not fail high. The history values is used as a replacement for LVA in [[MVV-LVA]].
  
 
=See also=  
 
=See also=  
Line 70: Line 85:
 
==2005 ...==  
 
==2005 ...==  
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=15337 Improving history tables] by [[Michael Sherwin]], [[CCC]], July 25, 2007
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=15337 Improving history tables] by [[Michael Sherwin]], [[CCC]], July 25, 2007
 +
* [https://www.talkchess.com/forum/viewtopic.php?t=18345 LMR: history or not?] by [[Alessandro Scotti]], [[CCC]], December 13, 2007
 
* [http://www.talkchess.com/forum/viewtopic.php?t=24920 killer moves and history heuristic table] by [[Stuart Cracraft]], [[CCC]], November 17, 2008 » [[Killer Heuristic]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=24920 killer moves and history heuristic table] by [[Stuart Cracraft]], [[CCC]], November 17, 2008 » [[Killer Heuristic]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=29611 Alternatives to History Heuristics] by [[Edsel Apostol]], [[CCC]], September 01, 2009
 
* [http://www.talkchess.com/forum/viewtopic.php?t=29611 Alternatives to History Heuristics] by [[Edsel Apostol]], [[CCC]], September 01, 2009

Latest revision as of 00:54, 24 July 2024

Home * Search * Move Ordering * History Heuristic

Alfred Agache - La Fortuna, 1885 [1]

History Heuristic,
a dynamic move ordering method based on the number of cutoffs caused by a given move irrespectively from the position in which the move has been made. The Heuristic was invented by Jonathan Schaeffer in 1983 [2] and works as follows: on a cutoff we increment a counter in a special table, addressed either by [from][to] (the Butterfly Boards) or by [piece][to] [3] . The added value is typically a multiple of depth or depth * depth, based on the assumption that otherwise moves from the plies near the leaves would have to much impact on the result. Values retrieved from that table are used to order non-capturing moves. This simple heuristics performs usually better than domain-dependent heuristics, though it may be combined with them. For example, in Stockfish all quiet moves that are not hash moves are ordered by history, while in Rebel only a few non-captures are ordered by history heuristics, then a piece-square approach is used [4] . In the literature, history heuristic is often presented as depth-independent generalization of the killer moves. It is also said to reflect long-term plans in a position.

Update

This is how the history array may be updated, if a beta-cutoff occurs:

if ( score >= beta ) { // cutoff
   if ( isNonCapture (move) )
      history[side2move][move.from][move.to] += depth*depth;
   ...
   return score;
}

Modern programs use a more sophisticated formula for history updates:

void update(Piece piece, Square to, int bonus)
{
    int clampedBonus = clamp(bonus, MAX_HISTORY, -MAX_HISTORY);
    history[piece][to] += clampedBonus - history[piece][to] * abs(clampedBonus) / MAX_HISTORY;
}

This scales up history updates when a beta cutoff is unexpected, and scales down history updates when a beta cutoff is expected. A beneficial side effect is that this formula also clamps history values from -MAX_HISTORY to MAX_HISTORY, which prevents oversaturated values.

Counter Moves History

A combination of the History Heuristic in conjunction with the Countermove Heuristic, proposed by Bill Henry in March 2015 [5] , as already used by Álvaro Begué in his Checkers program 20 years before [6] , was implemented by Stockfish contributor Stefan Geschwentner [7], further tuned and improved by the Stockfish community, and released in Stockfish 7 in January 2016, dubbed Counter Moves History and mentioned to gain some Elo points [8]. Stockfish's History and Countermove arrays are piece type and to-square based, not butterfly based. Each entry indexed by a previous move, is a complete history table with counters indexed by the move refuting that previous move. Pushing the idea further, Stockfish applies Follow Up History (FUH) tables, indexed by two consecutive moves of the same side [9].

Continuation History

Continuation History is a generalization of Counter Moves History and Follow Up History. An n-ply Continuation History is the history score indexed by the move played n-ply ago and the current move. 1-ply and 2-ply continuation histories are most popular and correspond to Counter Moves History and Follow Up History respectively. Many programs, notably Stockfish, also makes use of 3, 4, and 6-ply continuation histories.

Capture History

Capture History, introduced by Stefan Geschwentner in 2016, is a variation on history heuristic applied on capture moves. It is a history table indexed by moved piece, target square, and captured piece type. The history table receives a bonus for captures that failed high, and maluses for all capture moves that did not fail high. The history values is used as a replacement for LVA in MVV-LVA.

See also

Late Move Reduction Test Results

Selected Publications

1980 ...

2000 ...

Forum Posts

1995 ...

2000 ...

2005 ...

2010 ...

2015 ...

2020 ...

External Links

References

  1. Alfred Agache - Alegoria da Fortuna, 1885, Palais des Beaux-arts, Lille, Category:Alfred Agache - Wikimedia Commons
  2. Jonathan Schaeffer (1983). The History Heuristic. ICCA Journal, Vol. 6, No. 3
  3. Jos Uiterwijk (1992). Memory Efficiency in some Heuristics. ICCA Journal, Vol. 15, No. 2
  4. Move Ordering in Rebel by Ed Schröder, also available as pdf
  5. Improving History Tables by Bill Henry, CCC, March 02, 2015
  6. Re: Improving History Tables by Álvaro Begué, CCC, March 02, 2015
  7. Followup moves by Stefan Geschwentner, FishCooking, January 12, 2014 » Counter Moves History
  8. Re: Stockfish 7 progress by Lucas Braesch, CCC, January 17, 2016
  9. Re: CMH question by Lucas Braesch, CCC, December 09, 2019
  10. Negative Plausibility Move Ordering by Alessandro Damiani, CCC, July 09, 2009

Up one Level