From f9fe189e2942af8156e1d45f65a50922317c117b Mon Sep 17 00:00:00 2001 From: Alex Strokov Date: Thu, 16 Sep 2021 14:21:48 +0300 Subject: [PATCH] acceleration empirically confirmed --- a-star/heuristics.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/a-star/heuristics.js b/a-star/heuristics.js index 749c097..83fee62 100644 --- a/a-star/heuristics.js +++ b/a-star/heuristics.js @@ -2,6 +2,17 @@ module.exports = { l2: l2, l1: l1 }; +/** + * Distance squared; + * + * @param {*} a + * @param {*} b + */ +function l3(a, b) { + var dx = Math.abs(a.x - b.x); + var dy = Math.abs(a.y - b.y); + return Math.pow((dx + dy), 2); +} /** * Euclid distance (l2 norm);