An evaluation function is used to heuristically determine the relative value of a position, i.e. the chances of winning. If we could see to the end of the game in every line, the evaluation would only have values of -1 (loss), 0 (draw), and 1 (win). In practice, however, we do not know the exact value of a position, so we must make an approximation. Beginning chess players learn to do this starting with the value of the pieces themselves. Computer evaluation functions also use the value of the material as the most significant aspect and then add other considerations.
The first thing to consider when writing an evaluation function is how to score a move in Minimax or the more common NegaMax framework. While Minimax usually associates the white side with the max-player and black with the min-player and always evaluates from the white point of view, NegaMax requires a symmetric evaluation in relation to the side to move. We can see that one must not score the move per se – but the result of the move (i.e. a positional evaluation of the board as a result of the move). Such a symmetric evaluation function was first formulated by Claude Shannon in 1949 [2] :
f(p) = 200(K-K')
+ 9(Q-Q')
+ 5(R-R')
+ 3(B-B' + N-N')
+ 1(P-P')
- 0.5(D-D' + S-S' + I-I')
+ 0.1(M-M') + ...
KQRBNP = number of kings, queens, rooks, bishops, knights and pawns
D,S,I = doubled, blocked and isolated pawns
M = Mobility (the number of legal moves)
Here, we can see that the score is returned as a result of subtracting the current side's score from the equivalent evaluation of the opponent's board scores (indicated by the prime letters K' Q' and R'.. ).
Side to move relative
In order for NegaMax to work, it is important to return the score relative to the side being evaluated. For example, consider a simple evaluation, which considers only material and mobility:
and second if the function is homogeneous of degree 1:
It depends on the definition and independence of features and the acceptance of the axiom of choice (Ernst Zermelo 1904), whether additive real number functions are linear or not [3] . Features are either related to single pieces (material), their location (piece-square tables), or more sophisticated, considering interactions of multiple pawns and pieces, based on certain patterns or chunks. Often several phases to first process simple features and after building appropriate data structures, in consecutive phases more complex features based on patterns and chunks are used.
Based on that, to distinguish first-order, second-order, etc. terms, makes more sense than using the arbitrary terms linear vs. nonlinear evaluation [4] . With respect to tuning, one has to take care that features are independent, which is not always that simple. Hidden dependencies may otherwise make the evaluation function hard to maintain with undesirable nonlinear effects.
Eliot Slater (1950). Statistics for the Chess Computer and the Factor of Mobility, Proceedings of the Symposium on Information Theory, London. Reprinted 1988 in Computer Chess Compendium, pp. 113-117. Including the transcript of a discussion with Alan Turing and Jack Good
Jens Christensen, Richard Korf (1986). A Unified Theory of Heuristic Evaluation functions and Its Applications to Learning. Proceedings of the AAAI-86, pp. 148-152, pdf
Dap Hartmann (1987). How to Extract Relevant Knowledge from Grandmaster Games. Part 1: Grandmasters have Insights - the Problem is what to Incorporate into Practical Problems.ICCA Journal, Vol. 10, No. 1
Bruce Abramson (1989). On Learning and Testing Evaluation Functions. Proceedings of the Sixth Israeli Conference on Artificial Intelligence, 1989, 7-16.
Omid David, Moshe Koppel, Nathan S. Netanyahu (2008). Genetic Algorithms for Mentor-Assisted Evaluation Function Optimization, ACM Genetic and Evolutionary Computation Conference (GECCO '08), pp. 1469-1475, Atlanta, GA, July 2008.
Table of Contents
Where to Start
The first thing to consider when writing an evaluation function is how to score a move in Minimax or the more common NegaMax framework. While Minimax usually associates the white side with the max-player and black with the min-player and always evaluates from the white point of view, NegaMax requires a symmetric evaluation in relation to the side to move. We can see that one must not score the move per se – but the result of the move (i.e. a positional evaluation of the board as a result of the move). Such a symmetric evaluation function was first formulated by Claude Shannon in 1949 [2] :Here, we can see that the score is returned as a result of subtracting the current side's score from the equivalent evaluation of the opponent's board scores (indicated by the prime letters K' Q' and R'.. ).
Side to move relative
In order for NegaMax to work, it is important to return the score relative to the side being evaluated. For example, consider a simple evaluation, which considers only material and mobility:return the score relative to the side to move (who2Move = +1 for white, -1 for black):
Linear vs. Nonlinear
Most evaluations terms are a linear combination of independent features and associated weights in the form ofA function f is linear if the function is additive:
and second if the function is homogeneous of degree 1:
It depends on the definition and independence of features and the acceptance of the axiom of choice (Ernst Zermelo 1904), whether additive real number functions are linear or not [3] . Features are either related to single pieces (material), their location (piece-square tables), or more sophisticated, considering interactions of multiple pawns and pieces, based on certain patterns or chunks. Often several phases to first process simple features and after building appropriate data structures, in consecutive phases more complex features based on patterns and chunks are used.
Based on that, to distinguish first-order, second-order, etc. terms, makes more sense than using the arbitrary terms linear vs. nonlinear evaluation [4] . With respect to tuning, one has to take care that features are independent, which is not always that simple. Hidden dependencies may otherwise make the evaluation function hard to maintain with undesirable nonlinear effects.
General Aspects
Basic Evaluation Features
Considering Game Phase
Opening
Middlegame
Endgame
Miscellaneous
See also
Search versus Evaluation
Publications
1949
1950 ...
1960 ...
1970 ...
1980 ...
1990 ...
2000 ...
2010 ...
2015 ...
Blog & Forum Posts
1993 ...
1995 ...
2000 ...
2005 ...
Re: Search or Evaluation? by Mark Uniacke, Hiarcs Forum, October 14, 2007
2010 ...
- Correcting Evaluation with the hash table by Mark Lefler, CCC, February 05, 2010
- Re: Questions for the Stockfish team by Milos Stanisavljevic, CCC, July 20, 2010
- Most important eval elements by Tom King, CCC, September 17, 2010
- Re: 100 long games Rybka 4 vs Houdini 1.03a by Tord Romstad, CCC, November 02, 2010
- dynamically modified evaluation function by Don Dailey, CCC, December 20, 2010
2011- Suppose Rybka used Fruits evaluations by SR, Rybka Forum, August 29, 2011
- writing an evaluation function by Pierre Bokma, CCC, December 27, 2011
2012- The evaluation value and value returned by minimax search by Chao Ma, CCC, March 09, 2012
- Multi dimensional score by Nicu Ionita, CCC, April 20, 2012
- Bi dimensional static evaluation by Nicu Ionita, CCC, April 20, 2012
- Theorem proving positional evaluation by Nicu Ionita, CCC, April 20, 2012
- log(w/b) instead of w-b? by Gerd Isenberg, CCC, May 02, 2012
- The value of an evaluation function by Ed Schröder, CCC, June 11, 2012
2013- eval scale in Houdini by Rein Halbersma, CCC, January 14, 2013 » Houdini
- An idea of how to make your engine play more rational chess by Pio Korinth, CCC, January 25, 2013
- A Materialless Evaluation? by Thomas Kolarik, CCC, June 12, 2013
- A different way of summing evaluation features by Pio Korinth, CCC, July 14, 2013 [10] [11]
- Improve the search or the evaluation? by Jens Bæk Nielsen, CCC, August 31, 2013 » Search versus Evaluation
- Multiple EVAL by Ed Schroder, CCC, September 22, 2013
- floating point SSE eval by Marco Belli, CCC, December 13, 2013 » Float, Score
20142015 ...
- Value of a Feature or Heuristic by Jonathan Rosenthal, CCC, February 15, 2015
- Couple more ideas by Lyudmil Tsvetkov, CCC, April 05, 2015
- Most common/top evaluation features? by Alexandru Mosoi, CCC, April 10, 2015
- eval pieces by Daniel Anulliero, CCC, June 15, 2015
- * vs + by Stefano Gemma, CCC, July 19, 2015
- (E)valuation (F)or (S)tarters by Ed Schröder, CCC, July 26, 2015
2016- Non-linear eval terms by J. Wesley Cleveland, CCC, January 29, 2016
- A bizarre evaluation by Larry Kaufman, CCC, March 20, 2016
- Chess position evaluation with convolutional neural network in Julia by Kamil Czarnogorski, Machine learning with Julia and python, April 02, 2016 » Deep Learning, Neural Networks
- Calculating space by Shawn Chidester, CCC, August 07, 2016
- Evaluation values help by Laurie Tunnicliffe, CCC, August 26, 2016
- A database for learning evaluation functions by Álvaro Begué, CCC, October 28, 2016 » Automated Tuning, Learning, Texel's Tuning Method
- Evaluation doubt by Fabio Gobbato, CCC, October 29, 2016
2017- Bayesian Evaluation Functions by Jonathan Rosenthal, CCC, February 15, 2017
- improved evaluation function by Alexandru Mosoi, CCC, March 11, 2017 » Texel's Tuning Method, Zurichess
- random evaluation perturbation factor by Stuart Cracraft, CCC, April 24, 2017
- horrid positional play in a solid tactical searcher by Stuart Cracraft, CCC, April 29, 2017
- Another attempt at comparing Evals ELO-wise by Kai Laskos, CCC, May 22, 2017 » Playing Strength
- static eval in every node? by Erin Dame, CCC, June 09, 2017
- comparing between search or evaluation by Uri Blass, CCC, October 09, 2017» Search
- Neural networks for chess position evaluation- request by Kamil Czarnogorski, CCC, November 13, 2017 » Deep Learning, Neural Networks
- AlphaGo's evaluation function by Jens Kipper, CCC, November 26, 2017
- Logarithmic Patterns In Evaluations by Dennis Sceviour, CCC, December 09, 2017
2018External Links
Mathematical Foundations
Chess Evaluation
References
Up one level