Ive created better storage system for floyd-warshall pregenerated all-pair-paths that will cost
(((MOVE_MAP_NODES_IN_GRID ^ 2) * 32bits) / 2) of memory. thats twice better then original
((MOVE_MAP_NODES_IN_GRID ^ 2) * 32bits)
Thats for storage of all paths in grid.
Can somebody tell me what is the max and minimum number of movemap nodes in one grid?
New storage system is based on increasing cpu usage minimaly but decreasing memory requirements rapidly:
Old(something like this):
PathNode* AllPairPaths [MOVE_MAP_NODES_IN_GRID] [MOVE_MAP_NODES_IN_GRID];
GetPath (int i , int j)
{
if( AllPairPaths [i][j] == NULL )
output(i,j);
else
{
GetPath (i, AllPairPaths [i][j]);
GetPath (AllPairPaths [i][j], j);
}
}
New(something like this):
// id of node in grid up to 0xFFFF
uint32 AllPairPaths [MOVE_MAP_NODES_IN_GRID / 2][MOVE_MAP_NODES_IN_GRID];
GetPath(int i , int j)
{
uint32 word = NULL;
if( i & 1)
word = (AllPairPaths [(i >>1)+1][j] & 0xFFFF);
else
word = ((AllPairPaths [(i >>1)][j] & (0xFFFF << 4)) >> 4);
if(word == NULL)
output(i, j );
else
{
GetPath( i ,word);
GetPath(word, j);
}
}
every odd i is saved as 16bit LOW WORD
every even i is saved as 16bit HIGH WORD
maybe there are mistakes now, dont know
// Albrecht de Endrau // freeganja // Tvaroh //