Page 1 of 2

An idea of how to make your engine play more rational chess

Posted: Fri Jan 25, 2013 8:04 pm
by Pio
Hi!

I have watched some computer chess games and have been surprised of the risk the engines take sometimes.

I have come up with an idea that should not be too difficult to implement in an existing engine even though it will make the tuning of the engine harder.

What I hoope is that the idea will make your engine play/search more speculative when behind and more solid/boring when it is leading (not fun for the spectators when you are leading but hopefully good for your ELO)

The idea is that for each evaluation feature you will assign two values. One value should indicate the realistic/pessimistic value of the feature and another value should indicate the optimistic value of the feature.

Lets say that you have a big material advantage, maybe +2 pawns and you have the move. Should you really grab the opponent's rook with your queen, thus maybe trapping your queen, or should you go for the move that limits the opponent's mobility.

I think in the example above you should choose the boring move that limit the opponent's mobility. But on the other hand if you were behind 2 pawns I think you should take the rook and hope that your queen will be able to escape.

How is it possible to implement the idea?

Give high optimistic values for all features that might be really good such as king pressure, passed pawns, trapping of opponent pieces and low optimistic values for pieces. When you have summed up your optimistic and pessimistic values and the opponent's optimistic and pessimistic values for the position you should scale your and your opponent's optimistic values so that the one leading in terms of maybe (pessimistic value + optimistic value/(some constant)) should get a penalty based on the opponents optimistic vaue. Finally you will have a score that should represent the board's risk adjusted score.

Of course you could and probably should do the risk adjustment much more thorough.

Good luck with your engines!!!

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 8:23 pm
by Don
Pio wrote:Hi!

I have watched some computer chess games and have been surprised of the risk the engines take sometimes.

I have come up with an idea that should not be too difficult to implement in an existing engine even though it will make the tuning of the engine harder.

What I hoope is that the idea will make your engine play/search more speculative when behind and more solid/boring when it is leading (not fun for the spectators when you are leading but hopefully good for your ELO)

The idea is that for each evaluation feature you will assign two values. One value should indicate the realistic/pessimistic value of the feature and another value should indicate the optimistic value of the feature.

Lets say that you have a big material advantage, maybe +2 pawns and you have the move. Should you really grab the opponent's rook with your queen, thus maybe trapping your queen, or should you go for the move that limits the opponent's mobility.

I think in the example above you should choose the boring move that limit the opponent's mobility. But on the other hand if you were behind 2 pawns I think you should take the rook and hope that your queen will be able to escape.

How is it possible to implement the idea?

Give high optimistic values for all features that might be really good such as king pressure, passed pawns, trapping of opponent pieces and low optimistic values for pieces. When you have summed up your optimistic and pessimistic values and the opponent's optimistic and pessimistic values for the position you should scale your and your opponent's optimistic values so that the one leading in terms of maybe (pessimistic value + optimistic value/(some constant)) should get a penalty based on the opponents optimistic vaue. Finally you will have a score that should represent the board's risk adjusted score.

Of course you could and probably should do the risk adjustment much more thorough.

Good luck with your engines!!!
I have actually urged Larry to experiment with this idea long ago. I think it's perfectly valid. In particular, some evaluation features are just wild guesses, even in the best evaluation functions. If you are already winning by a nice margin I don't believe you should take huge risks to whip up a king side attack. For example should you give up a couple of pawns for this?

Another example. What is the value of a passed pawn on the 6th rank? The answer is, "it depends" and no program can really give you a very accurate answer. In fact it could be a liability if you have a difficult time defending it. In Komodo it's "a lot" with some conditions that help but anything this dynamic is a wild guess.

Now if you are a piece down, I would argue that a passed pawn in your favor is your only hope and should get more credit. But if you are up a piece already you should not treat it as the only thing you have going for you. You don't want to get yourself all twisted up over a pawn you might not be able to hold. I have seen winning games lost over this, usually being a pawn up but not being able to hold an advanced passed pawn and not being willing to convert it to a different advantage.

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 8:56 pm
by Pio
Hi Don!

I am happy that you do not think it is a stupid idea, mostly because I read most of your posts and more or less always have the same view as you have :)

I have a really nice idea for making automatic evaluation tuning and even for automatically dropping evaluation features. But that is for another thread. Implementing that idea and making a nice interface that everyone could use is another story :(

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 9:01 pm
by jd1
Hi Pio,

That is a very interesting idea and it makes sense to me. Will try it if I can get some time.

Jerry

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 9:10 pm
by Pio
Hi Jerry!

Thanks for trying the idea.

Keep up the good work with Toga!!!

Pio

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 9:55 pm
by Kempelen
This is my near todo list. My idea is if behind in material, play more aggresive, maybe more mobility and king safety bonus in eval, and extend more own aggresive moves, and if we are with more material, give more mobility and kind safety to opponent, extend less own moves and more opponent ones. I have side ideas around this.
This cames to my mind when talking with a IM, which talk me exactly that: style of play must be adjusted at what is in the possition: dynamical potencial or static (mainly material) potencial. Maybe looking at material only is not very accurate, but toying with the idea is interesting I think.

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 10:01 pm
by Don
Kempelen wrote:This is my near todo list. My idea is if behind in material, play more aggresive, maybe more mobility and king safety bonus in eval, and extend more own aggresive moves, and if we are with more material, give more mobility and kind safety to opponent, extend less own moves and more opponent ones. I have side ideas around this.
This cames to my mind when talking with a IM, which talk me exactly that: style of play must be adjusted at what is in the possition: dynamical potencial or static (mainly material) potencial. Maybe looking at material only is not very accurate, but toying with the idea is interesting I think.
The key is to identify evaluation that is reliable vs evaluation that is not nearly as reliable.

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 10:25 pm
by Kempelen
Don wrote:
The key is to identify evaluation that is reliable vs evaluation that is not nearly as reliable.
I have not yet test the idea, but I suspect find the correct evaluation terms is not an easy task, in fact, one can go wrong. You can be a pawn ahead, and need to attack in place of defense: as modern masters say, it all depend on the position

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 10:29 pm
by Don
Kempelen wrote:
Don wrote:
The key is to identify evaluation that is reliable vs evaluation that is not nearly as reliable.
I have not yet test the idea, but I suspect find the correct evaluation terms is not an easy task, in fact, one can go wrong. You can be a pawn ahead, and need to attack in place of defense: as modern masters say, it all depend on the position
I don't expect it to be easy but you should be able to get a gain if you work on it. Some evaluation is just plain speculative. Komodo king safety can say 4 or 5 pawns up, but if you are way ahead already there is no sense in giving up 4 or 5 pawns just for this. And you don't have to go crazy to get an improvement. I learned that long ago that sometime a small change has a bigger impact that you might think.

Re: An idea of how to make your engine play more rational ch

Posted: Fri Jan 25, 2013 10:49 pm
by AlvaroBegue
I thought about a similar method in the past, but I never did anything about it. My plan was to make an evaluation function that computes both the expected value of the evaluation of a depth-8 search (say) and its standard deviation. You can then use the logistic function to map scores to expected number of points earned in this game.

If you scale your scores appropriately, you can get the expected number of points earned in this game (0 for losing, 1/2 for drawing, 1 for winning) as approximately 1/(1+exp(-score)).

If you model your score as a normal distribution with mean m and standard deviation s, the expected number of points earned is

Integral(normal_distribution_density(x,m,s) / (1+exp(-x)))

where the integral is to be evaluated from -infinity to infinity. I will check with Mathematica to see if it can be done analytically, but I can always compute it numerically for a grid of values of m and s and then interpolate.

A large standard variation will naturally result in a bonus if you are behind and a penalty if you are ahead.