• Create Account

Banner advertising on our site currently available from just \$5!

### #Actualpatishi

Posted 02 July 2013 - 01:34 AM

And another quick question if i may, i know that after making a move (an actual one) i should empty the table and start fresh (please correct me if i am wrong) .

But what about if there is no depth limit..e.g if i am doing a complete tree search. Do i still need to reinitialize the table after each move?

EDIT: while the random numbers part is rather easy for me to understand.   from what i understood, one of the advantages of zobrist is that instead of hashing the entire board every time, one can update it's hash value by means of using XOR.   but i can't figure out how exactly should i do it in connect 4.  I would like to get some example if possible.
Or maybe this is not relevant in connect 4 since unlike chess,  the pieces are not moving on the board,just being added to it..??

EDIT2:  what do you say about those two functions.  one is initializing the table with random numbers and the other produce the hash code.  I need some review here
zobrist is a long [42] [2] array defined in the begining of this class

private void initZobrist(){
Random r = new Random();

for(int i = 0; i<42; i++){
for(int j = 0; j<2; j++){
zobrist[i][j] = r.nextLong();
}
}
}

public long hash(long[]board){
long hashValue = 0;
long y1 = board[0];  //white's bitBoard
long y2 = board[1];  //black's bitBoard

for(int i = 0; i<42; i++){
if((y1 & (1L<<i)) !=0){
hashValue ^= zobrist[i][0];
}

else if((y2 & (1L<<i)) !=0){
hashValue ^= zobrist[i][1];
}
}
return hashValue;
}

### #4patishi

Posted 02 July 2013 - 12:39 AM

And another quick question if i may, i know that after making a move (an actual one) i should empty the table and start fresh (please correct me if i am wrong) .

But what about if there is no depth limit..e.g if i am doing a complete tree search. Do i still need to reinitialize the table after each move?

EDIT: while the random numbers part is rather easy for me to understand.   from what i understood, one of the advantages of zobrist is that instead of hashing the entire board every time, one can update it's hash value by means of using XOR.   but i can't figure out how exactly should i do it in connect 4.  I would like to get some example if possible.
Or maybe this is not relevant in connect 4 since unlike chess,  the pieces are not moving on the board,just being added to it..??

### #3patishi

Posted 02 July 2013 - 12:38 AM

And another quick question if i may, i know that after making a move (an actual one) i should empty the table and start fresh (please correct me if i am wrong) .

But what about if there is no depth limit..e.g if i am doing a complete tree search. Do i still need to reinitialize the table after each move?

EDIT: while the random numbers part is rather easy for me to understand.   from what i understood, one of the advantages of zobrist is that instead of hashing the entire board every time, one can update it's hash value by means of using XOR.   but i can't figure out how exactly should i do it in connect 4.  I would like to get some example if possible.
Or maybe this is not relevant in connect 4 since unlike chess,  the pieces are not moving on the board...??

### #2patishi

Posted 02 July 2013 - 12:33 AM

And another quick question if i may, i know that after making a move (an actual one) i should empty the table and start fresh (please correct me if i am wrong) .

But what about if there is no depth limit..e.g if i am doing a complete tree search. Do i still need to reinitialize the table after each move?

EDIT: while the random numbers part is rather easy for me to understand.   from what i understood, one of the advantages of zobrist is that instead of hashing the entire board every time, one can update it's hash value by means of using XOR.   but i can't figure out how exactly should i do it in connect 4.  I would like to get some example if possible.

it seems that although the zobrist is a great hashing scheme, hashing every board i encounter can take a while (in order to probe the table for that board).  so i need to know what is the preffered method of using the zobrist keys.   thx!

### #1patishi

Posted 01 July 2013 - 10:48 PM

And another quick question if i may, i know that after making a move (an actual one) i should empty the table and start fresh (please correct me if i am wrong) .

But what about if there is no depth limit..e.g if i am doing a complete tree search. Do i still need to reinitialize the table after each move?

PARTNERS