"panic time" and "easy moves"

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: "panic time" and "easy moves"

Post by lucasart »

ZirconiumX wrote:
lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
He means an entire iteration of all the moves at the root node, not a call to the search.

Matthew:out
I don't understand the distinction you're trying to make. My search function, when called on the root node will iterate through all the moves at the root node. Can you clarify with some pseudo code ?
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Uri Blass
Posts: 10309
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: "panic time" and "easy moves"

Post by Uri Blass »

lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
I do not understand.
How can you not update the best move in the middle of an iteration.

Do you have a time when you searched part of the root moves but not all of them in some iteration?

In this case what do you do if a move failed high and you still did not finish the iteration because you did not search part of the root moves?

Common sense tell me that you change the root move and you can change the root move more than once in the same iteration.

For example you may have the following analysis:

1.e4 e5 0.2 pawns for white depth 2
1.e4 e6 2.d4 0.1 pawns for white depth 3
1.d4 fail high >=0.11 pawns for white depth 3
1.d4 d5 2.Nf3 0.15 pawns for white depth 3
1.Nf3 >=0.16 pawns for white depth 3
1.Nf3 Nf6 2.d4 0.17 pawns for white depth 3.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: "panic time" and "easy moves"

Post by lucasart »

Uri Blass wrote:
lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
I do not understand.
How can you not update the best move in the middle of an iteration.

Do you have a time when you searched part of the root moves but not all of them in some iteration?
Yes, it happens all the time with aspiration windows.
Uri Blass wrote: In this case what do you do if a move failed high and you still did not finish the iteration because you did not search part of the root moves?
In that case there was a fail low or a fail high from the aspiration window. So I resolve it by widening the window, and iterating the process, until the search has completed properly and returns a score inside the window. Only then is the iteration finished, and I can update the best move. There is no moment in that process I can think of, where I can update the best move. That is why I asked Bob what he meant by that.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

Re: "panic time" and "easy moves"

Post by ZirconiumX »

lucasart wrote:
Uri Blass wrote:
lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
I do not understand.
How can you not update the best move in the middle of an iteration.

Do you have a time when you searched part of the root moves but not all of them in some iteration?
Yes, it happens all the time with aspiration windows.
Uri Blass wrote: In this case what do you do if a move failed high and you still did not finish the iteration because you did not search part of the root moves?
In that case there was a fail low or a fail high from the aspiration window. So I resolve it by widening the window, and iterating the process, until the search has completed properly and returns a score inside the window. Only then is the iteration finished, and I can update the best move. There is no moment in that process I can think of, where I can update the best move. That is why I asked Bob what he meant by that.
If you get a score which is higher than your previous best (i.e. higher than alpha) print current best move. Simple, really.

Matthew:out
Some believe in the almighty dollar.

I believe in the almighty printf statement.
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: "panic time" and "easy moves"

Post by Joerg Oster »

lucasart wrote:
Uri Blass wrote:
lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
I do not understand.
How can you not update the best move in the middle of an iteration.

Do you have a time when you searched part of the root moves but not all of them in some iteration?
Yes, it happens all the time with aspiration windows.
Uri Blass wrote: In this case what do you do if a move failed high and you still did not finish the iteration because you did not search part of the root moves?
In that case there was a fail low or a fail high from the aspiration window. So I resolve it by widening the window, and iterating the process, until the search has completed properly and returns a score inside the window. Only then is the iteration finished, and I can update the best move. There is no moment in that process I can think of, where I can update the best move. That is why I asked Bob what he meant by that.
One iteration means searching all moves at a certain depth.
Formerly, engines updated the best move only when this iteration had finished. Nowadays, we update as soon as we find a new best move. That's what Bob was saying.
Jörg Oster
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: "panic time" and "easy moves"

Post by bob »

lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
As soon as you back up a score to ply 1, that move is the new best move and you can print it out instantly, and save it to be sure that is the move you play when time runs out...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: "panic time" and "easy moves"

Post by bob »

lucasart wrote:
ZirconiumX wrote:
lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
He means an entire iteration of all the moves at the root node, not a call to the search.

Matthew:out
I don't understand the distinction you're trying to make. My search function, when called on the root node will iterate through all the moves at the root node. Can you clarify with some pseudo code ?
Suppose you have 30 moves at the root. At the current point in time, you have only searched the first 3, and found that the second move in the list was better than the first. What do you do if you now note that you have used all the allotted time, and have to move right now. Do you play the move from the end of the previous search, or the new best move you just finished searching? I do the latter.
Volker Annuss
Posts: 180
Joined: Mon Sep 03, 2007 9:15 am

Re: "panic time" and "easy moves"

Post by Volker Annuss »

I am currently working on time for hard/easy moves for my new engine Arminius.

Both engines Hermann and Arminius use a neural network to calculate a probablity how likely it is in iterative deepening that the best move will change when going 1 ply deeper.
They both use properties of the position and results from previous iterations that are correlated with a change in the best move in the next iteration.

This is how it is done in Hermann. It does not use node counts because the parallel search with a shared hash table in Hermann sometimes gives bad node counts in the main search thread that controls the time.

In Arminius I also use node counts (more exact the fraction of nodes used for the best move and fraction of 2 inferior moves with the highest node counts).

When iteration d is finished the question is whether the best move will change at depth d+1.

This is correlated with:
- Change of best move from iteration d-1 to iteration d (pv[d][0] != pv[d-1][0])
- Fraction of nodes used for best, 2nd and 3rd root move
- Change of best move from iteration d-2 to iteration d-1 (pv[d-1][0] != pv[d-2][0])
- Change of best move from iteration d-3 to iteration d-2 (pv[d-2][0] != pv[d-3][0])
- Change of the pondermove from iteration d-1 to iteration d (pv[d][1] != pv[d-1][1])
- Change of the 3rd move in pv (pv[d][2] != pv[d-1][2])
- Score difference from d-1 to d
- Best move is a capture

Some less important properties:
- Best move gives check
- Transpositions in principal variation (pv[d][1] == pv[d-1][3] and/or pv[d][3] == pv[d-1][1])
- Number of legal root moves

The hash table is a problem for me too. But most of the time it introduces an error to the safe side. It takes nodes away from the best move which makes a change of the best move look more likely.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: "panic time" and "easy moves"

Post by lucasart »

bob wrote:
lucasart wrote:
ZirconiumX wrote:
lucasart wrote:
bob wrote:Back then, everyone just printed the best move at the end of the iteration, rather than what we all do today, printing a move whenever the best move gets replaced.
What do you mean ?
In DiscoCheck, I update the best move when an iteration is finished (including the fail low/high of aspiration windows). How can update the best move in the middle of an iteration ?
He means an entire iteration of all the moves at the root node, not a call to the search.

Matthew:out
I don't understand the distinction you're trying to make. My search function, when called on the root node will iterate through all the moves at the root node. Can you clarify with some pseudo code ?
Suppose you have 30 moves at the root. At the current point in time, you have only searched the first 3, and found that the second move in the list was better than the first. What do you do if you now note that you have used all the allotted time, and have to move right now. Do you play the move from the end of the previous search, or the new best move you just finished searching? I do the latter.
OK, thank you. That clarifies it all. Then I do the former, and will experiment with the latter.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: "panic time" and "easy moves"

Post by Kempelen »

To detect a easy move I do something different. I dont see if it is a recapture or a check. What I do is, before iterate loop start, do a search with depth = 1 with infinite windows for all moves. If the first is a EASY_MARGEN (can be , i.e. 150 or 200) above second one, I have a candidate easy move.
Then I calculate as normal the time to use. I do poll for time often, so if I detect when chrono > time_to_use / 4 and the pv move have not changed, I do it. I did some tests counting nodes for 1st move must be, at least 50% > 2th move when polling time, but I then moved to another feautes and take note in my to do. But that sounds reasonable to me.
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/