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 6 years ago
Edited 6 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
6 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 — 6y
0
yes DevingDev 346 — 6y
Ad

Answer this question