I'm not sure how the EVAL is normally done regarding material,
I always thought once you get to a leaf node, you just loop through
the pieces, adding the values for each piece.
It seems like a lot of work is being repeated at each leaf node,
so if you have a global variable MATERIAL initialized with material value of the board position about to be searched...
Then for each MAKE_MOVE, and UNDO_MOVE, you could remove the value of the piece from the FROM square, then add the value of the piece from the TO square.
Assuming a search tree with n plies, and branching factor b:
There would be b+b^2+...+b^n = b(b^n-1)/(b-1) total branches.
Since you have an undo move, you are really traversing 2b(b^n-1)/(b-1) branches.
During MAKE_MOVE:
Code: Select all
temp=-FROM_w+TO_w - TO_b //Assuming white captures a blackpiece
MATERIAL += temp
Code: Select all
MATERIAL -= temp
So with this method, there would be 4b(b^n-1)/(b-1) array-look-ups.
NEXT..
Considering the normal way I do evaluations, with the same tree as above, I would have b^n leaf nodes, so b^n evaluations.
Supposing each board contains P pieces, thats b^n*P array-look-ups.
Considering the inequality...
4b(b^n-1)/(b-1) < b^n*P
gives P >= 5 pieces (b>4 and n>1).
So with 5 or more pieces, using an incremental update for evaluation should be faster than doing the whole thing each time at each leaf node.
And with P=32 pieces, the effect should be even more dramatic, but I haven't calculated by how much yet.
Is this a good idea?