Difference between revisions of "Temporal Difference Learning"

From Chessprogramming wiki
Jump to: navigation, search
Line 210: Line 210:
==2020 ...==
==2020 ...==
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=72810 Board adaptive / tuning evaluation function - no NN/AI] by Moritz Gedig, [[CCC]], January 14, 2020
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=72810 Board adaptive / tuning evaluation function - no NN/AI] by Moritz Gedig, [[CCC]], January 14, 2020
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=77053 TD learning by self play (TD-Gammon)] by [[Chris Whittington]], [[CCC]], April 10, 2021
=External Links=
=External Links=

Revision as of 13:03, 12 April 2021

Home * Learning * Temporal Difference Learning

Temporal Difference Learning, (TD learning)
is a machine learning method applied to multi-step prediction problems. As a prediction method primarily used for reinforcement learning, TD learning takes into account the fact that subsequent predictions are often correlated in some sense, while in supervised learning, one learns only from actually observed values. TD resembles Monte Carlo methods with dynamic programming techniques [1]. In the domain of computer games and computer chess, TD learning is applied through self play, subsequently predicting the probability of winning a game during the sequence of moves from the initial position until the end, to adjust weights for a more reliable prediction.


Each prediction is a single number, derived from a formula using adjustable weights of features, for instance a neural network most simply a single neuron perceptron, that is a linear evaluation function ...

Sigmoid and Derivative

... with the pawn advantage converted to a winning probability by the standard sigmoid squashing function, also topic in logistic regression in the domain of supervised learning and automated tuning, ...


... which has the advantage of its simple derivative:



Each pair of temporally successive predictions P at time step t and t+1 gives rise to a recommendation for weight changes, to converge Pt to Pt+1, first applied in the late 50s by Arthur Samuel in his Checkers player for automamated evaluation tuning [2]. This TD method was improved, generalized and formalized by Richard Sutton et al. in the 80s, the term Temporal Difference Learning coined in 1988 [3], also introducing the decay or recency parameter λ, where proportions of the score came from the outcome of Monte Carlo simulated games, tapering between bootstrapping (λ = 0) and Monte Carlo predictions (λ = 1), the latter equivalent to gradient descent on the mean squared error function. Weight adjustments in TD(λ) are made according to ...


... where P is the series of temporally successive predictions, w the set of adjustable weights. α is a parameter controlling the learning rate, also called step-size, ∇wPk [4] is the gradient, the vector of partial derivatives of Pt with respect of w. The process may be applied to any initial set of weights. Learning performance depends on λ and α, which have to be chosen appropriately for the domain. In principle, TD(λ) weight adjustments may be made after each move, or at any arbitrary interval. For game playing tasks the end of every game is a convenient point to actually alter the evaluation weights [5].

TD(λ) was famously applied by Gerald Tesauro in his Backgammon program TD-Gammon [6] [7], a stochastic game picking the action whose successor state minimizes the opponent's expected reward, i.e. looking one ply ahead.


In games like chess or Othello, due to their tactical nature, deep searches are necessary for expert performance. The problem has already been recognized and solved by Arthur Samuel but seemed to have been forgotten later on [8] - rediscovered independently by Don Beal and Martin C. Smith in 1997 [9], and by Jonathan Baxter, Andrew Tridgell, and Lex Weaver [10], who coined the term TD-Leaf. TD-Leaf is the adaption of TD(λ) to minimax search, where instead of the corresponding positions of the root the leaf nodes of the principal variation are considered in the weight adjustments. TD-Leaf was successfully used in evaluation tuning of chess programs [11], with KnightCap [12] and CilkChess as most prominent samples, while the latter used the improved Temporal Coherence Learning [13], which automatically adjusts α and λ [14].


Don Beal

Don Beal in a 1998 CCC discussion with Jonathan Baxter [15]:

With fixed learning rates (aka step size) we found piece values settle to consistent relative ordering in around 500 self-play games. The ordering remains in place despite considerable erratic movements. But piece-square values can take a lot longer - more like 5000.
The learning rate is critical - it has to be as large as one dares for fast learning, but low for stable values.  We've been experimenting with methods for automatically adjusting the learning rate. (Higher rates if the adjustments go in the same direction, lower if they keep changing direction.)
The other problem is learning weights for terms which only occur rarely. Then the learning process doesn't see enough examples to settle on good weights in a reasonable time. I suspect this is the main limitation of the method, but it may be possible to devise ways to generate extra games which exercise the rare conditions. 

Bas Hamstra

Bas Hamstra in a 2002 CCC discussion on TD learning [16]:

I have played with it. I am convinced it has possibilities, but one problem I encountered was the cause-effect problem. For say I am a piece down. After I lost the game TD will conclude that the winner had better mobility and will tune it up. However worse mobility was not the cause of the loss, it was the effect of simply being a piece down. In my case it kept tuning mobility up and up until ridiculous values. 

Don Dailey

Don Dailey in a reply [17] to Ben-Hur Carlos Vieira Langoni Junior, CCC, December 2010 [18] :

Another approach that may be more in line with what you want is called "temporal difference learning", and it is based on feedback from each move to the move that precedes it. For example if you play move 35 and the program thinks the position is equal, but then on move 36 you find that you are winning a pawn, it indicates that the evaluation of move 35 is in error, the position is better than the program thought it was. Little tiny incremental adjustments are made to the evaluation function so that it is ever so slightly biased in favor of being slightly more positive in this case, or slightly more negative in the case where you find your score is dropping. This is done recursively back through the moves of the game so that winning the game gives some credit to all the positions of the game. Look on the web and read up on the "credit assignment problem" and temporal difference learning. It's probably ideal for what you are looking for. It can be done at the end of the game one time and scores then updated. If you are not using floating point evaluation you may have to figure out how to modify this to be workable. 

Chess Programs


See also



1970 ...

1980 ...

1990 ...

1995 ...





2000 ...





2005 ...





2010 ...





2015 ...



Forum Posts

1995 ...

Re: Parameter Tuning by Don Beal, CCC, October 02, 1998

2000 ...

Re: Temporal Differences by Guy Haworth, CCC, November 04, 2004 [21]

2010 ...

Re: Positional learning by Don Dailey, CCC, December 13, 2010
Re: Pawn Advantage, Win Percentage, and Elo by Don Dailey, CCC, April 15, 2012

2015 ...

2020 ...

External Links

temporal - Wiktionary


  1. Temporal difference learning from Wikipedia
  2. Arthur Samuel (1959). Some Studies in Machine Learning Using the Game of Checkers. IBM Journal July 1959
  3. Richard Sutton (1988). Learning to Predict by the Methods of Temporal Differences. Machine Learning, Vol. 3, No. 1, pdf
  4. Nabla symbol from Wikipedia
  5. Don Beal, Martin C. Smith (1998). First Results from Using Temporal Difference Learning in Shogi. CG 1998
  6. Gerald Tesauro (1992). Temporal Difference Learning of Backgammon Strategy. ML 1992
  7. Gerald Tesauro (1994). TD-Gammon, a Self-Teaching Backgammon Program, Achieves Master-Level Play. Neural Computation Vol. 6, No. 2
  8. Sacha Droste, Johannes Fürnkranz (2008). Learning of Piece Values for Chess Variants. Technical Report TUD–KE–2008-07, Knowledge Engineering Group, TU Darmstadt, pdf
  9. Don Beal, Martin C. Smith (1997). Learning Piece Values Using Temporal Differences. ICCA Journal, Vol. 20, No. 3
  10. Jonathan Baxter, Andrew Tridgell, Lex Weaver (1997) Knightcap: A chess program that learns by combining td(λ) with minimax search. 15th International Conference on Machine Learning, pdf via citeseerX
  11. Don Beal, Martin C. Smith (1999). Learning Piece-Square Values using Temporal Differences. ICCA Journal, Vol. 22, No. 4
  12. Jonathan Baxter, Andrew Tridgell, Lex Weaver (1998). Knightcap: A chess program that learns by combining td(λ) with game-tree search. Proceedings of the 15th International Conference on Machine Learning, pdf via citeseerX
  13. The Cilkchess Parallel Chess Program
  14. Don Beal, Martin C. Smith (1999). Temporal Coherence and Prediction Decay in TD Learning. IJCAI 1999, pdf
  15. Re: Parameter Tuning by Don Beal, CCC, October 02, 1998
  16. Re: Hello from Edmonton (and on Temporal Differences) by Bas Hamstra, CCC, August 05, 2002
  17. Re: Positional learning by Don Dailey, CCC, December 13, 2010
  18. Positional learning by Ben-Hur Carlos Vieira Langoni Junior, CCC, December 13, 2010
  19. Tao update by Bas Hamstra, CCC, January 12, 2001
  20. Nici Schraudolph’s go networks, review by Jay Scott
  21. Guy Haworth, Meel Velliste (1998). Chess Endgames and Neural Networks. ICCA Journal, Vol. 21, No. 4

Up one level