lucasart wrote:mike_bike_kite wrote:My little program (
Fun Chess ) plays OK at the moment but looses against many 1900+ players when they sacrifice material and go for it's king. The program happily believes it's doing fine until it finally realises that there's just no escape from mate.
I've tried evaluating the king safety bu just looking whether it's castled, the nearby pawn structure and how squares around the king are attacked or defended but this doesn't seem to be enough as the human player sacrificed a rook and a knight to eventually get mate.
I believe I have a few options:
- Raise the scoring on the existing safety routines. The problem here is that this will make the other evaluations seem insignificant ie why bother getting a protected passed pawn if it can add another minor piece to it's impregnable castle fortress.
I then looked at gathering safety info while doing the search ie if the opponents queen is moved near our king then score that badly. If the queen is taken then score that well. Checks bad. Mates worse etc etc. I tried putting in what I thought was moderate evaluation scores but found these scores were upsetting the whole scoring system.
Currently thinking about just counting the number of checks or mates that are found in any given search. If it exceeds a certain number then use the king safety evaluation function.
Essentially I'm trying anything that comes into my head. Any suggestions?
PS I'm hoping that when I have a better king safety evaluation then I might break the 2000 ELO barrier. Other options I've thought about adding include null moves, fractional extensions, hash positions and lazy evaluations. Any idea which of these might give most bang for the buck (or most ELO for hours coding)?
If you're program hasn't reached 2500 elo or so, I don't think you should spend time on a king safety. Better fix search bugs, and do a check and single reply extension. That should fix your king safety problem. To give you an idea, Fruit has no king safety and plays at 2700 elo or so...
The point is that if your program doesn't understand these sacrificial king attcks by search means, I don't think the eval will be able to compensate for the flaws of the search. Here's what I do in DoubleCheck, I suggest you give a try:
1/ check extension:
if the move is a check with a SEE >= 0, or if it's a revealed check (in which case the SEE is not to be trusted), then I extend by one ply.
2/ single reply extension:
if there's only one legal move in the position, I extend by one ply
=> that should already improve greatly the ability of your program to cope with "wild" positions.
In the eval, I don't have any king safety
All I have is in the pawn evaluation a king shelter bonus. Basically I look at the 3 squares in front of the king (Zone 1) and the 3 in front of those (Zone 2). I count a small bonus for a friendly pawn in Zone 1, and the same penalty for an enemy pawn in Zone 1. Same for Zone 2 dividing by 2 the bonus. The bonus I use is 4 centipawns. I'm not saying this is optimal in anyway, but it's simple and disincentivises stupid self weakening pawn pushes at least (conversly it incentivises pawn attacks on the enemy king's pawn shelter). A benefit of this is that it's done in the pawn eval and uses the pawn hash table (faster).