obvious/easy move

Discussion of chess software programming and technical issues.

Moderator: Ras

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: obvious/easy move

Post by bob »

bob wrote:
CRoberson wrote:Does it really work?

I mean if you don't quick exit on the "easy" move, it seems you
increase the probability of a ponder hit on the next move. If you make
the "easy" move, you reduce the ponder hit chances on the next move,
so it balances out. Or does it?

Making the "easy" move has risks:
1) I think it is likely to cut the chances of a ponder hit on next move
2) Sometimes the obvious move isn't so when given enough search time.

Who has data on this?
It works, and always has. If you notice, an "easy move" generally goes deeper anyway, because the one move is the only real choice.

There are generally "hints" about an easy move that can let you know that you ought to search it normally. For example, ANY fail-low during the search of the move ought to instantly terminate "easy mode" and force a normal search. You could probably (I don't any longer) look at the node counts for the ply-1 moves and if one (or more) is slowly creeping upward faster than the rest, that might serve notice. My easy move code is pretty restrictive.


If the first move is significantly better than the second and beyond, which in Crafty is 2.0 pawns, then I can trigger "easy move" in one of two ways:

(1) recapture, which means to capture the piece moved by the opponent on his last move; or

(2) the score for the first move is NOT winning material (but it is still +2 better than the second). Which is the case where (say) you have a piece attacked, it is not sufficiently defended, and you only have one move that saves it.

That has worked well for me for years. I might try a cluster test with it turned off to see what it is worth. I'll report on this maybe tonight. Will start the test shortly, just so there is a number to discuss...

test is running now...
Early results show a significant Elo gain/loss (gain with easy, loss without). Crafty 23.6 is current. 23.6R02 is identical except for easy_move being disabled. So far:

Code: Select all

 Crafty-23.6-1        2652    4    4 30000   62%  2557   25% 
 Crafty-23.6R02       2636   15   15  1540   60%  2556   26% 
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: obvious/easy move

Post by bob »

bob wrote:
bob wrote:
CRoberson wrote:Does it really work?

I mean if you don't quick exit on the "easy" move, it seems you
increase the probability of a ponder hit on the next move. If you make
the "easy" move, you reduce the ponder hit chances on the next move,
so it balances out. Or does it?

Making the "easy" move has risks:
1) I think it is likely to cut the chances of a ponder hit on next move
2) Sometimes the obvious move isn't so when given enough search time.

Who has data on this?
It works, and always has. If you notice, an "easy move" generally goes deeper anyway, because the one move is the only real choice.

There are generally "hints" about an easy move that can let you know that you ought to search it normally. For example, ANY fail-low during the search of the move ought to instantly terminate "easy mode" and force a normal search. You could probably (I don't any longer) look at the node counts for the ply-1 moves and if one (or more) is slowly creeping upward faster than the rest, that might serve notice. My easy move code is pretty restrictive.


If the first move is significantly better than the second and beyond, which in Crafty is 2.0 pawns, then I can trigger "easy move" in one of two ways:

(1) recapture, which means to capture the piece moved by the opponent on his last move; or

(2) the score for the first move is NOT winning material (but it is still +2 better than the second). Which is the case where (say) you have a piece attacked, it is not sufficiently defended, and you only have one move that saves it.

That has worked well for me for years. I might try a cluster test with it turned off to see what it is worth. I'll report on this maybe tonight. Will start the test shortly, just so there is a number to discuss...

test is running now...
Early results show a significant Elo gain/loss (gain with easy, loss without). Crafty 23.6 is current. 23.6R02 is identical except for easy_move being disabled. So far:

Code: Select all

 Crafty-23.6-1        2652    4    4 30000   62%  2557   25% 
 Crafty-23.6R02       2636   15   15  1540   60%  2556   26% 
Later results: Looks like -11 Elo to remove this, at the moment.

Code: Select all

 Crafty-23.6-1        2652    4    4 30000   62%  2557   25% 
 Crafty-23.6R02       2641    7    7  8515   60%  2558   25% 
[code]

Something is running on the cluster at the moment, so instead of getting all 70 nodes (8 cores per node) I can only use 8 nodes, or 64 games at a time.  This is without pondering, I believe the Elo will drop just a bit with pondering on, because when I have an easy move, my opponent is certainly going to be pondering the right reply, and doing a full search will give him a free ponder hit, easy move makes him spend at least 2/3 of his normal search time since it is not very likely that he also has an easy move reply...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: obvious/easy move - final results

Post by bob »

bob wrote:
bob wrote:
bob wrote:
CRoberson wrote:Does it really work?

I mean if you don't quick exit on the "easy" move, it seems you
increase the probability of a ponder hit on the next move. If you make
the "easy" move, you reduce the ponder hit chances on the next move,
so it balances out. Or does it?

Making the "easy" move has risks:
1) I think it is likely to cut the chances of a ponder hit on next move
2) Sometimes the obvious move isn't so when given enough search time.

Who has data on this?
It works, and always has. If you notice, an "easy move" generally goes deeper anyway, because the one move is the only real choice.

There are generally "hints" about an easy move that can let you know that you ought to search it normally. For example, ANY fail-low during the search of the move ought to instantly terminate "easy mode" and force a normal search. You could probably (I don't any longer) look at the node counts for the ply-1 moves and if one (or more) is slowly creeping upward faster than the rest, that might serve notice. My easy move code is pretty restrictive.


If the first move is significantly better than the second and beyond, which in Crafty is 2.0 pawns, then I can trigger "easy move" in one of two ways:

(1) recapture, which means to capture the piece moved by the opponent on his last move; or

(2) the score for the first move is NOT winning material (but it is still +2 better than the second). Which is the case where (say) you have a piece attacked, it is not sufficiently defended, and you only have one move that saves it.

That has worked well for me for years. I might try a cluster test with it turned off to see what it is worth. I'll report on this maybe tonight. Will start the test shortly, just so there is a number to discuss...

test is running now...
Early results show a significant Elo gain/loss (gain with easy, loss without). Crafty 23.6 is current. 23.6R02 is identical except for easy_move being disabled. So far:

Code: Select all

 Crafty-23.6-1        2652    4    4 30000   62%  2557   25% 
 Crafty-23.6R02       2636   15   15  1540   60%  2556   26% 
Later results: Looks like -11 Elo to remove this, at the moment.

Code: Select all

 Crafty-23.6-1        2652    4    4 30000   62%  2557   25% 
 Crafty-23.6R02       2641    7    7  8515   60%  2558   25% 
[code]

Something is running on the cluster at the moment, so instead of getting all 70 nodes (8 cores per node) I can only use 8 nodes, or 64 games at a time.  This is without pondering, I believe the Elo will drop just a bit with pondering on, because when I have an easy move, my opponent is certainly going to be pondering the right reply, and doing a full search will give him a free ponder hit, easy move makes him spend at least 2/3 of his normal search time since it is not very likely that he also has an easy move reply...[/quote]

OK, this is one of those GOOD exampls of why you should not draw conclusions after even 8500 games.  Here is the 30K game final results:

[code]

   2 Crafty-23.6-1        2652    4    4 30000   62%  2557   25%
   3 Crafty-23.6R02-1     2651    4    4 30000   62%  2557   25%
In short, no measurable difference with ponder = off.
JBNielsen
Posts: 267
Joined: Thu Jul 07, 2011 10:31 pm
Location: Denmark

Re: obvious/easy move

Post by JBNielsen »

bob wrote:
JBNielsen wrote:
bob wrote:
CThinker wrote:Let's take the trivial easy case - that is, you have a single reply. Should you still do a search just so you can populate your PV and have something to ponder on?

I think that one should not do a search in this case. Instead, on the opponents time, do a search to find a move to ponder on, then do the ponder.

We can extend the idea to the general easy case. Make the move and save time, then on the opponents time, do any ponder-related operations.
agreed...
Even if the engine skips the last iteration, it will probably have reached the usual depth because the recapture score will give a lot of cut-offs when the other moves are examined.

What if there are two recapture moves? Do we have to spend all the time to choose between two moves, when we normally have to choose among 40 moves?
I would like to save some time here, too.
Harder question. Which one is the better way to recapture? There I think you need a normal search, although I suppose you could always keep up with your nominal search depth move by move, and whenever you reach that depth quickly, in such a 2-move scenario, you could stop early. That seems more risky. Why are we searching so fast? Because we have two obvious choices out of 40? Or because we THINK we have two obvious choices, but we are missing some key tactical point that more depth would spot?
Your results indicate that there are some elo-gain in this. So why don't try to get another bit with 2 or 3 good moves? Please notice I write good moves; not only recaptures...

There is always a risk of stopping a search early, but I believe the time is better spent in positions where many moves are candidates for the best move.

Humans have the same strategy, and I think it is wise.

I have not made this in Dabbaba yet, but your results makes me want to implement something like this:

Don't start a new iteration if more than x% of the time for this move is used.

x = 35 - 8 * z + 2 * y

y = the number of moves (max 3) that are z centipawns better than the rest.
z is the biggest gap among the 4 best moves. z is max 3.00.

x is always 45% if the biggest gap is less than 0.20 or we have a matescore.

x = 13% if 1 move recaptures a queen (z=3.0)

x = 15% if 2 moves recaptures a bishop (z=3.0)

x = 31% if 2 moves recaptures a pawn (z=1.0)

x = 33% if 1 move is z=0.50 better than the rest

x = 39% if 3 moves are z=0.25 better than the rest.

Notice I try to take advantage of small gaps too....

This is just a quick shot that must be refined - but the point is, that there may be some elo in a better time disposition.

I hope your results give us further information.
AlvaroBegue
Posts: 932
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: obvious/easy move - final results

Post by AlvaroBegue »

bob wrote:OK, this is one of those GOOD exampls of why you should not draw conclusions after even 8500 games. Here is the 30K game final results:

Code: Select all


   2 Crafty-23.6-1        2652    4    4 30000   62%  2557   25%
   3 Crafty-23.6R02-1     2651    4    4 30000   62%  2557   25%
In short, no measurable difference with ponder = off.
That's exactly what I suspected. This type of thing doesn't happen very often, and when it does it just saves a bit of time, so the improvement would be similar to a very minor speed up (say, 1%), which I don't expect to be measurable in ELO.

Thanks for running this!
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: obvious/easy move

Post by lucasart »

AlvaroBegue wrote:My engine Ruy-López has always had an obvious-move heuristic, and it has always worked very well. I don't think it has a measurable ELO effect, but my perception is that it's more pleasant to play against an engine that has this feature, and that's why we have it.
100% agreed. I've tried the easy move stuff, and tried also to restrict it, in order to limit side effects. I've never been able to measure any elo gain from it.

But as you say, it's just annoying to see when your engine takes a long time to think on an obvious move. It just looks pathetic. It's like adding KBNK knowledge to your code: it adds code, but absolutely zero elo (can even be a regression depending on whether implementation slows down the general case or not). It's a matter of taste. I suppose polished commercial engines typically want to have these features, as users will complain if they don't. But I really don't care, and have taken the stance that any code patch that is not a measurable elo gain is useless, and therefore evil.

The only time my search exits immediately, is you have only 1 legal move (that can't hurt).
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: obvious/easy move

Post by bob »

JBNielsen wrote:
bob wrote:
JBNielsen wrote:
bob wrote:
CThinker wrote:Let's take the trivial easy case - that is, you have a single reply. Should you still do a search just so you can populate your PV and have something to ponder on?

I think that one should not do a search in this case. Instead, on the opponents time, do a search to find a move to ponder on, then do the ponder.

We can extend the idea to the general easy case. Make the move and save time, then on the opponents time, do any ponder-related operations.
agreed...
Even if the engine skips the last iteration, it will probably have reached the usual depth because the recapture score will give a lot of cut-offs when the other moves are examined.

What if there are two recapture moves? Do we have to spend all the time to choose between two moves, when we normally have to choose among 40 moves?
I would like to save some time here, too.
Harder question. Which one is the better way to recapture? There I think you need a normal search, although I suppose you could always keep up with your nominal search depth move by move, and whenever you reach that depth quickly, in such a 2-move scenario, you could stop early. That seems more risky. Why are we searching so fast? Because we have two obvious choices out of 40? Or because we THINK we have two obvious choices, but we are missing some key tactical point that more depth would spot?
Your results indicate that there are some elo-gain in this. So why don't try to get another bit with 2 or 3 good moves? Please notice I write good moves; not only recaptures...

There is always a risk of stopping a search early, but I believe the time is better spent in positions where many moves are candidates for the best move.

Humans have the same strategy, and I think it is wise.

I have not made this in Dabbaba yet, but your results makes me want to implement something like this:

Don't start a new iteration if more than x% of the time for this move is used.

x = 35 - 8 * z + 2 * y

y = the number of moves (max 3) that are z centipawns better than the rest.
z is the biggest gap among the 4 best moves. z is max 3.00.

x is always 45% if the biggest gap is less than 0.20 or we have a matescore.

x = 13% if 1 move recaptures a queen (z=3.0)

x = 15% if 2 moves recaptures a bishop (z=3.0)

x = 31% if 2 moves recaptures a pawn (z=1.0)

x = 33% if 1 move is z=0.50 better than the rest

x = 39% if 3 moves are z=0.25 better than the rest.

Notice I try to take advantage of small gaps too....

This is just a quick shot that must be refined - but the point is, that there may be some elo in a better time disposition.

I hope your results give us further information.
These scores are not very reliable. I take each root move, make it, and do a regular quiescence search, just to get an idea. I am not so sure that stopping early when you only have two good moves is worthwhile, since stopping early with just one produced no significant elo gain...
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: obvious/easy move

Post by lucasart »

JBNielsen wrote: y = the number of moves (max 3) that are z centipawns better than the rest.
z is the biggest gap among the 4 best moves. z is max 3.00.
And how do you calculate that ?
Once you search the first move alpha is raised!
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
JBNielsen
Posts: 267
Joined: Thu Jul 07, 2011 10:31 pm
Location: Denmark

Re: obvious/easy move

Post by JBNielsen »

lucasart wrote:
JBNielsen wrote: y = the number of moves (max 3) that are z centipawns better than the rest.
z is the biggest gap among the 4 best moves. z is max 3.00.
And how do you calculate that ?
Once you search the first move alpha is raised!
"My engine is probably not written the standard way. I started it 18 years ago based on what I had read and my intuition and logic.
When a white move at the root is refused by a given black move, I store the score for the move that gave the cuf-off."

It is copied from this thread
http://www.talkchess.com/forum/viewtopi ... =&start=10
JBNielsen
Posts: 267
Joined: Thu Jul 07, 2011 10:31 pm
Location: Denmark

Re: obvious/easy move - final results

Post by JBNielsen »

bob wrote:
OK, this is one of those GOOD exampls of why you should not draw conclusions after even 8500 games. Here is the 30K game final results:

Code: Select all


   2 Crafty-23.6-1        2652    4    4 30000   62%  2557   25%
   3 Crafty-23.6R02-1     2651    4    4 30000   62%  2557   25%
In short, no measurable difference with ponder = off.
Perhaps it is a good example of that 30K is not enough :wink:
Or an error has occured - are the programs different?

It could be interesting to change an engine so it gave these informations:

How much time is saved by playing easy moves fast?
How often would it play the same move with a normal use of time?
When the moves differs, what is the difference in the scores (how many centipawns are lost)?

And then evt. try to open up for more timesavings if there are only 2 or 3 good moves...


- - -

Another issue about timedisposition.
I have always avoided to start a new iteration, if it probably will stop the search after examining only one move. It takes a long time to examine the first move, and it is the same move as we found in the previous iteration.
But it gives the option to extend the search if the move turns out to be bad, though.
Is it right to do it this way?!