Need help in code for alpha beta With TT

Code, algorithms, languages, construction...
Post Reply
patishi
Posts: 1
Joined: Mon Jun 10, 2013 8:48 pm

Need help in code for alpha beta With TT

Post by patishi » Mon Jun 10, 2013 9:22 pm

Hi all. I know that this question was asked before,but it seems that i still don't quite get it..
I have the following alpha beta function (JAVA) ,and also a transposition table with all the necessary methods. but i need some technical help in what to insert to the table and what to get from it when i do a prob. in case of a lower or upper bound (whatever it is...) do i need to change the alpha or the beta only? (not returning the score) and only in an exact value should i use the score as the definite score of the board? i need a step by step instructions on what exactly to do and when.
this is my alpha beta function below,can you please please help me to add the TT part to it?

EDIT: oh..and something strange,even when i tried to save positions with an exact value (when no alpha beta break has accured) i also got strange results for some reason. without the TT on,this alpha beta function works fine,but when i try to incorporate the TT it returned incorrect moves sometimes

public Best chooseMove(boolean side,int alpha,int beta,int depth){
Best myBest = new Best();
Best reply;

if(Board.checkGameOver(newBoard)||depth==0){
Best fakeBest = new Best();
fakeBest.setScore(returnPositionScore(newBoard));
return fakeBest;
}
if(side){
myBest.setScore(alpha);
}
else{
myBest.setScore(beta);
}
ArrayList<Integer>availableMoves = searchAvailableMoves(newBoard);
for(Integer move:availableMoves){
makeMove(move);
reply = chooseMove(!side,alpha,beta,depth-1);
unmakeMove(move);
if(side&&reply.getScore()>myBest.getScore()){
myBest.setMove(move);
myBest.setScore(reply.getScore());
alpha = reply.getScore();
}
else if(!side&&reply.getScore()<myBest.getScore()){
myBest.setMove(move);
myBest.setScore(reply.getScore());
beta = reply.getScore();
}
if(alpha>=beta){
return myBest;
}
}
return myBest;
}

syzygy
Posts: 148
Joined: Sun Oct 16, 2011 4:21 pm

Re: Need help in code for alpha beta With TT

Post by syzygy » Wed Jun 12, 2013 2:24 am

patishi wrote:i need a step by step instructions on what exactly to do and when.
this is my alpha beta function below,can you please please help me to add the TT part to it?
I'm afraid that if your understanding is at this level, you can as well just copy & paste the relevant code from one the many open source engines available. If you want us to write part of your code, why not let us write your whole engine ;-)

If that's not what you want, then take a lot of time to study how alpha/beta works. From there on you should be able to work out step by step how to integrate a transposition table into your search.

In any event, as you already said, there are many threads on this topic. There is not much point in anyone typing it all out once more.

http://www.open-chess.org/viewtopic.php?f=5&t=1872

Post Reply