samedi 6 décembre 2014

Heuristic and Distance in A* algorithm


Vote count:

0





float distance1(Maze* yarrak, int start, int end, int width)
{
int x0 = start % width;
int x1 = end % width;

int y0 = start / width;
int y1 = end / width;


int z0 = maze->tiles[start].altitude;
int z1 = maze->tiles[end].altitude;

int dx = x0 - x1;
int dy = y0 - y1;
int dz = z0 - z1;

return sqrtf(dx*dx + dy*dy + dz*dz);
}


int heuristic(Maze* yarrak, int start, int end, int width)
{
return abs(start % width - end % width) + abs(start / width - end / width);
}


It's my first post. I want to know if my code for distance is true or not(because i used int and i found float for the distance) ? and i want to know if heuristic is a good one or not ? Thanks



asked 29 secs ago







Heuristic and Distance in A* algorithm

Aucun commentaire:

Enregistrer un commentaire