How can I force my program to give his best analysis?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Samuele Giraudo

How can I force my program to give his best analysis?

Post by Samuele Giraudo »

Hello,

I want to interface my engine with the UCI protocol and so I have to implement the required functions.

One of them is - return the result of the engine analysis - and my problem is how can I stop the search procedure and return the line calculated ?

What I have to add in the alpha-beta function to do that?

Regards.
Samuele
User avatar
Bill Rogers
Posts: 3562
Joined: Thu Mar 09, 2006 3:54 am
Location: San Jose, California

Re: How can I force my program to give his best analysis?

Post by Bill Rogers »

I don't think you stop your search, I think that after you program makes its move then you just print the the PV and its final score.
I may be wrong but this is what it looks like to me.
Bill
CRoberson
Posts: 2055
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: How can I force my program to give his best analysis?

Post by CRoberson »

Under UCI there are a couple of ways to stop.
1) your engine receives the stop command.
2) your timer algorithm says its time to move.

There are multiple parts to the answer.
a) you need code in the search that will detect the stop message
b) you need to check the time periodically to know its time to stop the search.

The easiest way to do both a & b is to put something in your iterative
deepening routine that tests for one of the two events before starting
a search on the next depth.

Most put a test in the search itself, but that is more complicated that
it seems you are ready for.

Regardless of which way you do it, when the iterative deepening routine
sees its time to stop search it prints pv, best value, best move and
any other information you want to send to the UCI GUI via the "info"
command.
Samuele Giraudo

Re: How can I force my program to give his best analysis?

Post by Samuele Giraudo »

I don't understand how to test efficiently if I can search more deeply in the iterative deepening because I can't estimate the time needed to finish the search at deep d + 1.
For example, assume I have finished the search at deep d and I have 20 sec to continue the search. If the search at deep d + 1 takes 50 sec, how can I stop the search when the 20 sec are spent and return the analysis of deep d (the best analysis found completely) ?

Regards.
plattyaj

Re: How can I force my program to give his best analysis?

Post by plattyaj »

Samuele Giraudo wrote:I don't understand how to test efficiently if I can search more deeply in the iterative deepening because I can't estimate the time needed to finish the search at deep d + 1.
For example, assume I have finished the search at deep d and I have 20 sec to continue the search. If the search at deep d + 1 takes 50 sec, how can I stop the search when the 20 sec are spent and return the analysis of deep d (the best analysis found completely) ?

Regards.
At the root you keep the move you found at depth d. When you are doing the search at d+1 you check the time at intervals and see if it's expired. Depending on your code you might find it easier to then return a 'TimedOut' status all the way back up to the root or else use some form of exception or setjmp mechanism to get back to the root.

At the root you look at the reason you returned. If it's because of a timeout you return the move you found at depth d.

You can use this same mechanism to halt analysis if the GUI tells you to stop.

Andy.
Samuele Giraudo

Re: How can I force my program to give his best analysis?

Post by Samuele Giraudo »

Thanks!

It's very simple !
AndrewShort

Re: How can I force my program to give his best analysis?

Post by AndrewShort »

later, you will realize that throwing away all the work from a timed out iteration is bad. If you ensure the next iteration always tries the last iteration's 1st move first, then you can simply return Alpha from within the search upon timeout. The act of returning Alpha gets you out of the recursion, undoing moves along the way for you, and updating the PV as appropriate. Then, the timed out iteration will return a move from a deeper search, which is always better. Often, it's the same move anyway, but sometimes not and that makes it worth it.