Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I calculate Manhattan/Euclidean distance?

This isn't even really a question for Roblox itself, since it has it's own pathfinding, but how do I calculate heuristics for Manhattan/Euclidiean distance for A*. I'm pretty sure euclidian is like square root of (a-c) + (b-d), and Manhattan is like (a-c) + (b-d).

Is this correct?

1 answer

✓ Accepted answer

You could calculate it like this:

local abs = math.abs;
local function ManhattanDistance(a, b)
	return abs(a.X - b.X) + abs(a.Y - b.Y) + abs(a.Z - b.Z);
end

2 comments

0

I see, so I just put in 2 parts positions, and it will return the heuristic. Is this correct?

0

yes

This discussion is preserved as it was. New answers, comments, and votes are closed.