fix auto-attack targeting

This commit is contained in:
2025-01-13 11:45:26 +09:00
parent 49a4d3e924
commit 03bbea4862
8 changed files with 32 additions and 134 deletions
+14 -7
View File
@@ -4,19 +4,26 @@ import PriorityQueue from './priority-queue.js'
import SATX from './satx.js'
export default class Pathfind {
static precision = 0.001
static multiplier = 1000 // (1 / this.precision)
static precision = 0.01
static multiplier = 1000000 // (1 / this.precision) * 10^expected_digit_count / 10
static key2(a, b) {
return `${a},${b}`
}
// TODO: Value exceeds safe integer limit: collisions cause waypointing anomalies
// Fowler-Noll-Vo hash prime and offset basis for small keyspaces
static floatKey4(a, b, c, d) {
return Math.floor(a * Pathfind.multiplier) +
Math.floor(b * Pathfind.multiplier) * Pathfind.multiplier +
Math.floor(c * Pathfind.multiplier) * Pathfind.multiplier ** 2 +
Math.floor(d * Pathfind.multiplier) * Pathfind.multiplier ** 3
const prime = 16777619
let result = 2166136261
result ^= Math.floor(a * Pathfind.multiplier)
result *= prime
result ^= Math.floor(b * Pathfind.multiplier)
result *= prime
result ^= Math.floor(c * Pathfind.multiplier)
result *= prime
result ^= Math.floor(d * Pathfind.multiplier)
result *= prime
return result
}
static uniqueWaypoints(waypoints) {