Pradu wrote:hristo wrote:The functions that generate KE and PE take into account minimum amount of chess rules and a few assumptions, however none of those can be considered "chess knowledge", at least not in the way other programs are using this term.
The KE function(s) (logically speaking there are really just two of them, one for pawns and one for everything else) don't have any special cases with respect to positions or particular piece configurations, those functions require the current position only so the generated energy map can follow the rules of chess. There is no explicit knowledge about "doubled pawns", "rook on the 7th", "trapped bishop", "open line", etc. etc. The only aspects of the position that those functions are concerned with are:
1) Is a square occupied by a piece?
1.1) Is this opponent piece?
1.2) Is this own pawn?
Does the type of piece matter? Or is it only that the piece type is occupied?
The only piece type that is treated "differently" is the pawns for the side to move. The primary reason for this is that I was too lazy to write the code to handle them in a generic way, so instead I use them as units that block the energy for the side to move, which is what they do more often than not.
Pradu wrote:
This is it. No other information is extracted from the position during energy map generation.
Can your energy function(s) recognize doubled pawns as bad and passed pawns as good even though you haven't explicitly coded it? If it can, what is the definition of energy you use for pawns.
Doubled pawns are not immediately "bad" but depending on the position they often lead to reduced energy score. There are several reasons as to why this might happen:
1) The pawns have a single energy vector and when they are doubled (tripled) the pawns that are behind have their energy vector blocked which leads to reduction of energy.
2) Doubled pawns create little barriers for the energy propagation of the other pieces of the same color -- reduces overall KE -- but they don't reduce the Energy for the opponent since they can be captured. (this is situational)
3) They create lumpiness in the energy that more often than not seems to have negative impact on the overall energy. (this is very situational and probably doesn't have a huge effect. Besides it is difficult to visualize or predict, I observed it but don't know what to make of it.)
Passed pawns are considered "good" because their energy vector extends all the way to the promotion square. When building the energy map for such pawn the energy of the promoted piece (hardcoded to Queen) is added to the map of the pawn, and even though this additional energy is greatly reduced based on the distance to promotion, it has measurable effect on the total energy calculation.
Pradu wrote:
The reason to use two different KE generation functions is that pawns "behave" drastically different from the other pieces and I couldn't figure out how to merge this behavior into one function.
Pradu wrote: Do you have something like KE + PE = 0 or something like KE + PE = Change in total energy in the system from a move?
I have tried both. Currently am using the KE+PE = Change in total E, not because it is inherently better, but because it is easier for me to understand.
Pradu wrote: If so what do you do to generate a score when the KE and PE of a position is known.
The easiest way of looking at it is that we have two sets of KE and PE:
For white: wKE + wPE = wTE
For black: bKE + bPE = bTE
Because the measured quantity, the total energy for a side will change for every move, there is no need to split it up into kinetic and potential components right? (Because every move will cause a change in the energy of the system so perhaps we can't use any conservation laws to benefit anything). Lets say a Knight has a PE=0.5 at b1. If one plays Nc3 it's PE becomes 0.4 and it's KE becomes 0.1. But we do know the score is better when it's at c3; so, there can't be any conservation of energy and the move adds energy to the system to say make it PE = 0.5, KE = 0.1. Now lets say it goes back to b1. If energy was conserved it would suggest PE=0.6, KE=0.0. But we know it's value is less so lets say the move removes energy from the system and it becomes PE=0.5, KE=0.0. But what you will be measuring here is the change in the total energy so perhaps there's no advantage to separating KE and PE from the total energy because nothing is going to get conserved.
Excellent point!!!
I wrestled with this issue for a long time and didn't want to introduce PE, using similar argumentation as you. It was about a year ago when I managed to convince myself that PE is needed or is beneficial to the Energy evaluation. Without looking through my notes (source code comments) here are some of the reasons for PE:
1) The KE for a piece could be negligible in some positions while other pieces could easily gain more KE. In this case the Evaluation would drop the undeveloped piece way too easily. This convinced me that KE (only) is not a sufficiently accurate representation or that the energy maps (KE) is not constructed properly. Since I couldn't figure out a better way to build KE map I opted for introducing PE.
2) The eval takes into account the ratio between the KE of both sides. Thus it is possible to make a move that doesn't increase the KE for the side to move but it reduces the KE for the opponent. The consequence of this is that, again, the eval tends to drop undeveloped pieces like flies. (follows the same as #1)
3) The presence of pieces on the board limits the KE they can achieve and this also leads to "desire" to remove some of your own pieces to maximize the KE of the others.
The PE is the maximum possible energy that a piece can have when there are only kings on the board. So, what I did, create a position with just two kings and calculate the energy then add a single piece, calculate again and subtract the Kings-only energy map.
Pradu wrote:
and then try to maximize the TE for the side to move while minimizing the TE for the opponent. The ratio between wTE and bTE is what drives the final score.
In the case where the result from the position is known (say a "mate" is found) the return value that I'm using is +INFINITY. Although this is not necessary, since the ratio would be 1.0, i.e. the opponent has no Energy left.
Ok I think you meant the score is done such that score=wTE/(wTE + bTE) because the ratio would be zero or infinity if one side didn't have any energy for score = wTE/bTE.
Of course.
If black are mated then they would have no energy etc.
Pradu wrote:
Pradu wrote: Also what information is in the datastream for the FFT and what do you do with the (I'm guessing peak-power) frequencies obtained from power spectrum?
The energy maps is what drives the FFT. These maps are two dimensional (2D FFT) and provide information about energy distribution within the system and not just the peak, i.e. band-power is IMO more valuable than absolute peak-power.
What do you do with the frequency domain representation of the energy distribution. You will get a measure of how periodic the energy distribution is but how will this help in generating the score. Also won't there be problems with aliasing? You have to sample the energy distribution at a little above the Nyquist frequency of highest frequency of your data set. Say you had a signal that alternated RMS energy every square. This would require a sampling which would sample a little more than 2 times every square, but we have no such things as half-squares. The FFT suggests that this signal is actually two or more sinusoids of a lower frequency, but it could very well be a signal with a much higher frequency. So what do you do to avoid aliasing problems.
This is all true and it would be a problem if I were interested in the actual frequency domain information. However, what is important (to me) is the total power of the system which is not effected by the aliasing in frequency. As I said earlier the FFTs are not needed, as such, but are fun. In my case the band-power is the entire position and not a particular part of the board.
Pradu wrote:As you can imagine at this point in the evaluation we are completely removed from any notion of "chess knowledge".
Pradu wrote:
Indeed it sounds like a very expensive eval if you have to generate a datastream for each position and do an FFT on it, but I guess one would need to do some testing to see if the quality of the knowledgeless eval is good enough to offset the loss in search depth.
I don't know if this is better than the "built in chess knowledge" approach, but the sheer novelty factor makes it more fun to experiment with. In fact, this approach might not lead to a better playing chess program.
There are many different ways to generate the Energy maps and even more ways to analyze them. For instance the FFTs are not necessary, but it is surely fun to see a spectrogram of a chess position.
New ideas are always nice, even if they don't work out at first.
Regards and Good morning,
Hristo
Yes my sleep schedule is off because of a lot of things...
Best Regards and Good morning (again
),
Hristo