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

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Pio
Posts: 119
Joined: Sat Feb 25, 2012 9:42 pm
Location: Stockholm
Contact:

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

Post by Pio » Fri Jan 25, 2013 7:04 pm

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!!!

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

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

Post by Don » Fri Jan 25, 2013 7:23 pm

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.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

Pio
Posts: 119
Joined: Sat Feb 25, 2012 9:42 pm
Location: Stockholm
Contact:

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

Post by Pio » Fri Jan 25, 2013 7:56 pm

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 :(

jd1
Posts: 266
Joined: Wed Oct 24, 2012 12:07 am

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

Post by jd1 » Fri Jan 25, 2013 8:01 pm

Hi Pio,

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

Jerry

Pio
Posts: 119
Joined: Sat Feb 25, 2012 9:42 pm
Location: Stockholm
Contact:

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

Post by Pio » Fri Jan 25, 2013 8:10 pm

Hi Jerry!

Thanks for trying the idea.

Keep up the good work with Toga!!!

Pio

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 9:44 am
Location: Madrid - Spain
Contact:

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

Post by Kempelen » Fri Jan 25, 2013 8:55 pm

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.
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

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

Post by Don » Fri Jan 25, 2013 9:01 pm

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.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 9:44 am
Location: Madrid - Spain
Contact:

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

Post by Kempelen » Fri Jan 25, 2013 9:25 pm

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
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

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

Post by Don » Fri Jan 25, 2013 9:29 pm

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.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

AlvaroBegue
Posts: 920
Joined: Tue Mar 09, 2010 2:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

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

Post by AlvaroBegue » Fri Jan 25, 2013 9:49 pm

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.

Post Reply