Experimenting with killer moves and history heuristic,and a question

Started by
17 comments, last by patishi 10 years, 9 months ago

I think the statement is pretty clear. You are searching some node and you have a list of moves in an array:

move[0] = 17;
move[1] = 5;
move[2] = 11;
//...

You explore move 17 and it doesn't produce a beta cutoff, you explore move 5 and it doesn't produce a beta cutoff, you explore move 11 and it does produce a beta cutoff. Then you do

history[17]--;
history[5]--;
history[11]+=2;

I gave you a detailed explanation in post #2 in this thread...

Advertisement

thx, that's what i thought. i tried to implement it just like that but for any reason it still don't cut as much branches as the killer moves do. so right now i am with the killer moves, although i may give the history another try, maybe try to implement it better.

You can always use the history heuristic for moves that are not killers. That's what we typically do in chess.

And one more thing..i know this is kind of stupid question, but i just want to be sure. when a move doen not(!) cause a cut off , than he gets only one point right?

And one correction about the explanation above, isn't it more precise to give the cut off move another point beside the moves that were before it? for example,in your example alvaro, maybe instead of 2 points it should get 3? my reasoning is that the added point is his own actually + the point of all the previews moves tried, and the second and more important reasoning for this is that if it is the first move that has been tried and it causes a cut off than it should at least get one point.... am i mistaken here?

I didn't understand your first question.

Why would you want to change anything in the history table if the first move gives you a cutoff? The table seems to be working as intended, so don't touch it. But ultimately, it comes down to testing what works best.

it seems that i also added points to non-cut off moves, e.g best move after a search, that's the explanation for the first question above.
But now i switched to only score cut off moves, and there may have been a tiny improvement. also, it doesn't seem that the hash move is doing anything special..with or without it, the speed is roughly the same. i am using the two big replacement scheme in the TT , and ordering the moves just like john tromp explains...but still it takes too much time in certain positions. (by the way, i abandoned the evaluate for one move idea..it's not that good smile.png )

And most of my code is fast, not so very different for the john tromp bitBoard implementation. the one thing i think that can contribute to the slowness is my getMoves() method. i am creating a java ArrayList in every alpha beta function which hold all the move. inside this function, I also sort the moves according to the History table with bubble sort kinda loop..but with java methods such as : set(index,element) etc.. which also can be very slow i think. (not like sorting a normal array).
The reasin i am using java array list is because i can't know in advance how much available columns i have in a position, and a normal array is a fixed size structure..while i need a dynamic structure.

Ofcourse there are ways to increase the array side dynamiacally but it involving recreat new array every time i need to add an element. (that's actually what the array list is doing in the background + some other bonus stuff that can cause even more slowness).
I wasn't able to figure out a way to iterate and sort the moves inside the alpha beta without making a hell of a mess in my code smile.png


The reasin i am using java array list is because i can't know in advance how much available columns i have in a position, and a normal array is a fixed size structure..while i need a dynamic structure.

7. You need 7 elements in an array, and a variable to tell you how many of the 7 entries are actually being used. Using dynamic memory allocation for this is kind of crazy.

I thought you said that your program was as fast as John Tromp's, but now it's obvious that it's not. How many positions per second is it exploring?

You should consider spending some time programming in C. That kind of abuse of dynamically allocated memory is something I have seen in many Java programmers, and it's something you should educate yourself against. I think learning C and a bit of assembly would teach you a lot of valuable things. C++ would also do the job, but C is a small language that can be learned in a few weeks, while C++ is a monster that takes years to learn.

I knew that this getMoves() function is slow, but i didn't realize that the java implementation is that bad..but i guess that for this sort of programms, which need absolutely the minimum of operation in the fastest time, this is really too much. except for this function almost everything is "Bit oriented" so no especial slowness there... when looking at john tromp's code, i can see that he is doing the sorting of the moves (by the history table) "in place" inside the alpha beta. I will work on that, and also try to avoid using the array list operations. This is no tic tac toe AH?... :)

This is for me to solve,so don't answer me right now. but just to explain my "stupidity" by using the java array list:
I know that the total number columns in the game is 7 right..? but not all the time all of them is playable (e.g a column can be totally full).
so what i did is: ArrayList moves = new ArrayList(); and then pass through all the columns from 0 to 7 (actually i am doing it from the center and outside to improve the move ordering a little bit. I have an array columns = {3,2,4,1,5,0,6} ) and doing from(i to 7) { if ! fullColumn, than - moves.add(i) } and that's how i get a list that holds all the PLAYABLE columns. (which in the alpha beta i am just playing one after the other)

So if i want to create a normal array inside the alpha beta, and this array has to be declared on some initial size... let's say for example - array moves - new int[7];
and than i can do: from (i to 7) if !fullColumn, moves = i; or something like this.. but than i have an array of size 7 but some indexes can be empty (or equal to 0, this is the default of int in java). now, even in this way i can say that if a columns is full than i put a -1 in the array, that's how i know that i don't need to play this index, but i can't sort the columns by the HH that way...that's my main problem! so i need to figure out how to initialize this array and how to allocate it. I read your comment above abouto holding an variable that tells me how many elements i can use, but i didn't understand it (yet).

If i didn't need to sort this array by the HH, than i could just do from (i to 7) if( !fullColumn) make move... etc'. but i need to first create an array of all the playable columns and sort it before i can use it. and i can't just do moves.add(i) with a normal array, only with an arraylist.

I hope i can figure this out on my own.. if not i will come back

This topic is closed to new replies.

Advertisement