Sign in to follow this  
ashish123

Retriving Optimum moves calculated from both sides

Recommended Posts

Here I am facing a bot of trouble as how to retrive the PVS that was searched.
I am having hashtable which is correctly implemented.
I think there has to be a way in which this hash table will be useful to retrive the best moves which are searched for both sides in the game tree.
But unfortunately, I am unable to determine how to do it.
kindly help.
Thank you.

Share this post


Link to post
Share on other sites
Does your hash table contain a field indicating the best move found (as it should)? If that's the case, it's very straight forward: Make a copy of the current board; play the best move on it; search for the resulting position in the hash table, and if the entry is exact, use it; rinse; repeat.

There are other more reliable methods to back out the PV in the search. Take a look [url="http://chessprogramming.wikispaces.com/Principal+Variation"]here[/url].

Share this post


Link to post
Share on other sites
@alvaro: I dont think I understand your solution.

I have hash tables which has the following fields:
hashDepth[]=contains depth where the key is stored.
hashkey[]=contains keys of the postions.
hashval[]=values of the position
hashtype[]=type of the position, hashalfa or hashbetaor hashexact, referd from [url="http://web.archive.org/web/20070809015843/http://www.seanet.com/%7Ebrucemo/topics/hashing.htm"]brucemoreland pages[/url].

I saw programs which gives out the lines that they think are the best for each player. I think this can be achieved from hashtables but dont know how can I do it.
I saw this is chess programs where they give lines as follows:

1.e4
1.e4-e5
1.e4-e5 2.Nf3-Nc6...


I have now put in a field which will contain the bestMoves but then how to fill it up and from where to update it.
General strucutre of my program is:

[code]if (hashkey[hIndex] == zob_key) {


if (hashDepth[hIndex] >= (depth)) {

if (hashType[hIndex] == hashexact) {

return hVal[hI];
}
if ((hashType[hIndex] == hashalpha) && (hashVal[hIndex] <= alpha)) {


return alpha;
}
if ((hashType[hIndex] == hashbeta) && (hashVal[hIndex] >= beta)) {

return beta;
}
}
}[/code]
later on proceed with normal PVS.
update the hashtable on alpha and beta cutoffs.
I tried to update the bestmove here as bestMove[count++]=legalMoves[i];
but then its giving me illegal move order.

Perhaps some code or pseudocode might help me understand better.
Thank you.

Share this post


Link to post
Share on other sites
You should have a field for a best move in the hash table. At the point of the search where you store information in the hash tables, I am sure you know (or you can easily modify the code so you know) what move was the best found in this search, or which one caused a beta cutoff. If you store it in the hash tables, you can improve your move-order heuristics by trying the move from the hash table first, even if you couldn't use the score in the hash table because the hashDepth wasn't enough. As a side effect, you can also use this field to retrieve the PV, as I described above.

An unrelated comment: Having a large array of structures instead of several parallel arrays would probably improve the cache friendliness of your program.

Share this post


Link to post
Share on other sites
Thanks for replying and trying to help me with this.
I browsed through the link that you gave, however, there is no code or pseudocode given by which I can think of, they all being a high level programers, I am unable to realize what they call to be very easy, I havent reached to their level as yet.

I have managed to collect the PV in an array but now a funny thing has happend.
My program searches through the moves and returns the first move which caused cutoff rather than last.
but when I fill my array with PVs, it fills with latest moves which cause cutoff.
now the PV which is printed printouts different (The latest moves which caused cutoff) where as my getMove method will always consider the first move which caused the cutoff.
One more issue is it doesnt handle the score. Say if its win in one move, then it will go on printing the latest moves which has caused cutoff rather than going for immediate win in PV. However there are no issues with playing strength, it plays same as before and will play moves which will get it an instant win. However it doesnot reflect in the PV.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this