|
Clericus 1.03 / Hopeless 0.5 evaluation |
||||||||||||||
|
|
At the initialization of TEval class, a table of "neighbouring squares" is created. These are squares near to the king, used for attack calculation. Please note that not only neighbouring squares in the strict sense of the word are treated as such - program looks also at the three more distant squares in front of the King (by "front" I mean the direction towards enemy position). For each sliding piece, a boolean function "IsAttacker" is fired. It checks if a piece attacks a square neighbouring enemy king, as defined above. This is done in the usual manner of sliding along the ray, as in move generation routine. The only exception is that the process is continued even after a ray is blocked - in that case a local variable called "masks" is increased by one. It denotes number of pieces standing on the attacker's path - and the attack counts as such if at most one such piece exists. Boolean result of the function indicates that we have found an attacker, which in turn increases a counter declared in TEval class. The strength of attack (basically a number of important squares under attack multiplied by a factor depending on the attacking piece) is added to the value of TEval.WPressure/BPressure variable. Similar function "IsKnightAttacker" counts attack value for the knights as well as their mobility (please forgive faulty design). Attack algorithm is similar to the one described above, except that there is no question of interfering pieces.
The stuff described above is the core of Clericus' king safety. However, a couple of additional factors are also taken into account. The most important of them is the pawn shield. For example, the rooks on open or half-open files are more valuable if the files are in the vicinity of the enemy king, the queen is awarded a slight bonus for approaching the enemy king and a slight penalty for going away from it. Also the fianchetto evaluation proved itself very helpful in a couple of games. Material value Don't sneer: Clericus thinks that purely material value of a pawn depends on its placement on the board. Central pawn are considered more valuable, whereas rook pawns, which can capture only in one direction, are considered slightly weaker due to their poorer mobility. Weak pawns Weak pawns are defined as either isolated or backward. Hanging pawns currently do not fall into this cathegory, as they would need more elaborate evaluation. All weak pawns receive a penalty from the piece/square table, and further penalty of -5, if they stand on the open file. The table is constructed in such a way that the penalty increases towards the center. This decision is based on the following assumption: a weak pawn in the center can be attacked from more directions, therefore it constitutes far more serious problem. The maximum penalty is -16, the minimum -10. Doubled pawns Doubled pawns receive a penalty of -20. Tripled pawns, which are much worse, get -60. Passed pawns This is the part that definately needs correction. Passed pawns receive a bonus from a piece/square table, which is multiplied by 1.2 if the passer is defended by another pawn or if it has a neighbour on the same rank. At this moment program knows nothing about piece placement affecting the value of a passed pawn. Pawn shield My pawn shield evaluation routine may seem too simplistic, but it's good enough for this program. If a pawn is near enough to the own king, we assign a bonus (PROT_PAWN); A pawn which is too advanced gets no bonus, and with no pawns on a file near the king we impose a penalty (NO_PROT_PAWN). Pawn center Program gives bonuses for certain constellations of the pawns in the center. A long time ago, when my program played without the opening book, I decided that the notion of pawn center is asummetric: most of the time the pawn center is built by the means of supporting the "d" pawn - be it by defending it or by giving it a neighbour on c4 or on e4. Thus playing c2-c3 is vieved as more valuable than f2-f3. It is caused mostly by the factors not known to the evaluation function of Clericus: c2-c3 increases queen mobility (which isn't counted) and the square f3 is much more necessary for the knight than the square c3 (which might have to do with the distance to the enemy king). Class TEval contains functions "WPRelations" and "BPRelations", which evaluate factors depending on the pawn structure. At present they include the following:
Fianchetto and long term plans associated with it are extremely difficult to evaluate for a computer. This part of the code had changed several times before reaching the current state.
Mobility evaluation in Clericus/Hopeless Chess can be described by a set of five rules:
Mobility calculation involves scanning the board for a possible piece moves. Therefore it constitutes a sound framework for checking attacks on stronger enemy pieces, rook connection and so on. For details, please refer to the source code. There are solutions which would enhance the mobility calculation even further. For example, many programs read the bonus from the tables depending on a piece type and a number of available squares; it can make sense to allow a rook "see through" another one in the forward direction etc. However, these changes are low on my priority list, since they would be very cost-effective in terms of testing time and especially in relation to the possible Elo gain. Therefore it may pay off to postpone them until my program reaches at least 2300 Elo level. By the means of defining several attack patterns, program knows about a couple of typical sacrifices, like Bxh7 or the "trojan horse" sacrifice on g5. This is achieved by describing the positions after such tactical shots and awarding them substantial bonuses. I don't think that this solution increases the playing strength by a significant amount, but I really enjoyed coding those exceptional situation and seing the engine solve them accurately. Knights, Bishops and Rooks are awarded mobility bonuses or penalties, as described above. Rooks and Knights may get outpost bonuses, if this option is set in the .ini file. All pieces except of the king contrubute to the king safety value. 1. Knight
2. Bishop
Please note that fianchetto is evaluated as a part of advanced pawn structure terms in WPRelations or BPRelations, and a bishop pair is dealt with as a correction of material value. 3. Rook
4. Queen
5. King
This part of evaluation function description is concerned with all sorts of not very significant details, which nevertheless contribute to more natural "feel" of Clericus' games.
Draw rules:
The last two points may sound quite complicated, so I will take a liberty to supply a drawing:
|