Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I calculate Manhattan/Euclidean distance?

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by
DevingDev 346 Moderation Voter
5 years ago

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
0
I see, so I just put in 2 parts positions, and it will return the heuristic. Is this correct? ronitrocket 120 — 5y
0
yes DevingDev 346 — 5y
Ad

Answer this question