feedback7: the battle sim uses engine-independent math — Chrome, Firefox, Safari and the server agree bit for bit (PR #373 by @Cloudnyco)
- server/sim/detmath.js: hypot (sqrt of the squares, rescaled outside 2^±500), powi (integer powers in double-double, one rounding), sin / cos (fdlibm 5.3) and atan2 (fdlibm / FreeBSD msun) built only from correctly rounded IEEE operations; the sim's Math.hypot / sin / cos / atan2 / pow calls go through it (65 files); eslint.config.js forbids the approximated Math functions under server/sim and test/sim/detmath.test.js scans for them. - sin / cos / atan2 are the algorithms V8 runs in Node, so the server's results stay; only hypot differs from V8's. Golden: 2 moved — diy-027 (a hypot distance, damage +80) and coop3-ABYSS-5 (a later card pick from round 9, same end). - Applied unchanged after review (Grok static review: MERGE; the diff read in full: no network, no new dependency). - Tests: broad node --test 5155 / 5155 with the new file tracked (detmath 7 / 7, package 10 / 10); lint 0 errors, typecheck, check:imports.
This commit is contained in:
1 parent
2580152a3a
commit
ae22335cfe
65 files changed
+616
-141
No files matched your search
@@ -116,6 +116,7 @@ import { REFLECTION_KITS } from './enemies/reflection.js';
|
||||
import { FLY_KITS } from './enemies/fly.js';
|
||||
import { SPECIAL_KITS } from './enemies/special.js';
|
||||
import { LEADER_KITS } from './enemies/leaders.js';
|
||||
import { hypot } from '../detmath.js';
|
||||
|
||||
export {
|
||||
EROSION, EROSION_BURST, HUSK_REBIRTH, nthOf, abOf, attach, T, silenced, canCast, elem, hurt, alliesInTiles,
|
||||
@@ -312,7 +313,7 @@ function chaliceShare(b, c) {
|
||||
for (const o of b.enemies) {
|
||||
if (!o.alive || o === t || o.defId !== 'enemy_1430_lrrook' || !o.mem.ab) continue;
|
||||
const a = o.mem.ab.list[0];
|
||||
if (!a || !(a.share > 0) || Math.hypot(o.x - t.x, o.y - t.y) > a.r) continue;
|
||||
if (!a || !(a.share > 0) || hypot(o.x - t.x, o.y - t.y) > a.r) continue;
|
||||
const part = c.dmg.amount * a.share;
|
||||
c.dmg.amount -= part;
|
||||
// a 无来源 burst's share stays 无来源, credited like the burst (damage.js)
|
||||
|
||||
Reference in new issue
Block a user