I like to experiment, even when my experiment lead to a "cul de sac". Tonight i've experimented a new idea. In my satana engine i've a class to store a single move and a fixed array for all moves. This class has some data: a flag+value 64 bit integer, an alfavalue to store result of last iteration and a little more. Profiling the code, a good 30% of the time is spent in sorting, specially in data moving. I thinked to avoid all this data copying using a moves pointers array, at the side of real moves data but this would need to handle some new pointers in move generation: the pointer to current move and the pointer to the array of the pointers (or use a single index, maybe). To avoid this, i've thinked to try "interleaved move pointers array". The idea is simple: in any move object i store... the pointer to the move itself. When i sort moves, i only sort the pointers. After quicksort, any move object can contains a pointer to another move. When i loop through moves, i only have to access the move pointed by the move pointer, instead of the move object itself.
Code: Select all
// before:
for(clsMove *pLoopMove=pFirstmove; pLoopMove<pLastMove; pLoopMove++)
{
DebugMove(pLoopMove);
}
// after:
for(clsMove *ppLoopMove=pFirstmove, *pLoopMove=ppLoopMove->pMove; ppLoopMove<pLastMove; pLoopMove = (ppLoopMove++)->pMove)
{
DebugMove(pLoopMove);
}
Of course this will requires a specialized quicksort function, to copy only the pointers in clsMove objects.
i think that interleaved move pointers could give better performance than using a separate array, because pointers reside in the same chunk of memory than pointed moves.
I'm debugging this new idea and i will give you some data about performance gain... or loss!
