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:
Cloudnyco authored and sganggs committed 2026-10-08 18:35:55 +08:00
1 parent 2580152a3a
commit ae22335cfe
65 files changed
+616 -141

No files matched your search

+11 -11
View File
@@ -1085,26 +1085,26 @@
"bossHpLeft": null,
"rngDraws": 0,
"errors": {"count":0,"kinds":[]},
"players": {"p1":{"killed":111,"total":111,"perfect":true,"leaks":0,"leaksUncounted":0,"coins":0,"dmg":1987984,"bossDmg":0,"heal":0,"deaths":0,"layerGains":{}}},
"players": {"p1":{"killed":111,"total":111,"perfect":true,"leaks":0,"leaksUncounted":0,"coins":0,"dmg":1988064,"bossDmg":0,"heal":0,"deaths":0,"layerGains":{}}},
"units": [
["p1",1,"op","chess_char_5_diy1_b",0,"uniequip_002_narant",2331,1,10,9,139430,0,0,91,1],
["p1",2,"op","chess_char_5_diy2_b",1,"uniequip_002_narant",2331,1,11,5,155980,0,0,88,3],
["p1",3,"op","chess_char_5_diy1_b",2,"uniequip_002_narant",2331,1,1,0,740,0,0,5,0],
["p1",4,"op","chess_char_5_diy2_b",0,"uniequip_003_narant",2541,1,3,1,12484,0,0,4,1],
["p1",5,"op","chess_char_5_diy1_b",1,"uniequip_003_narant",2541,1,5,16,222860,0,0,87,3],
["p1",6,"op","chess_char_5_diy2_b",2,"uniequip_003_narant",2541,1,7,11,255194,0,0,170,4],
["p1",7,"op","chess_char_6_diy1_a",0,null,2000,1,9,18,305504,0,0,107,1],
["p1",8,"op","chess_char_6_diy2_a",1,null,2000,1,12,23,447750,0,0,177,4],
["p1",5,"op","chess_char_5_diy1_b",1,"uniequip_003_narant",2541,1,5,18,216963,0,0,85,3],
["p1",6,"op","chess_char_5_diy2_b",2,"uniequip_003_narant",2541,1,7,11,262559,0,0,170,4],
["p1",7,"op","chess_char_6_diy1_a",0,null,2000,1,9,19,302382,0,0,106,1],
["p1",8,"op","chess_char_6_diy2_a",1,null,2000,1,12,27,452511,0,0,177,4],
["p1",9,"op","chess_char_6_diy1_a",2,null,2000,1,2,0,251,0,0,5,0],
["p1",10,"op","chess_char_6_diy2_b",0,"none",2331,1,4,0,12573,0,0,4,1],
["p1",11,"op","chess_char_6_diy1_b",1,"none",2331,1,6,18,198679,0,0,90,3],
["p1",12,"op","chess_char_6_diy2_b",2,"none",2331,1,8,10,236538,0,0,173,4]
["p1",11,"op","chess_char_6_diy1_b",1,"none",2331,1,6,10,197025,0,0,89,3],
["p1",12,"op","chess_char_6_diy2_b",2,"none",2331,1,8,11,235164,0,0,173,4]
],
"enemies": {"enemy_1010_demon":[54,54,0,0,755827],"enemy_1320_wdrrl_2":[18,18,0,0,839808],"enemy_1422_lrsldr_2":[39,39,0,0,400308]},
"hooks": [1,123,5886,1001,1001,2296,2296,0,111,111,25,20,0,9735,233,0,111,0,1,111,0,0,0],
"events": {"atk":1001,"deploy":12,"die":111,"dmg":2296,"engage":12,"fx":453,"skill":45,"spawn":123,"status":245},
"fx": {"aoe":137,"bounce":316},
"snaps": "b054f186 5f1791df 62fad2b9 772b925e 3c33e5ff 792df80b b43d3d8f 4283ce62 933a9c03 44991c3e b9347ef2 941827a5 73c09893 9ddf9d2c dbaf0a96 63e46fbe d21c76f5 55bdfa26 bfaf6c80 6968f2d8"
"hooks": [1,123,5886,997,997,2292,2292,0,111,111,25,20,0,9744,235,0,111,0,1,111,0,0,0],
"events": {"atk":997,"deploy":12,"die":111,"dmg":2292,"engage":12,"fx":451,"skill":45,"spawn":123,"status":251},
"fx": {"aoe":137,"bounce":314},
"snaps": "b054f186 5f1791df 3d017ddc 6caa5d05 8c321828 7e0d74c4 924d8c48 bc44fa99 448a38b4 f74013c9 0e587d4d 2185ab3b 9482eaf7 c6e6f386 7ce17fa6 af9ad4b3 97bb47c5 500c935b 824afe6d 6e3d1bcb"
},
"diy-028": {
"about": "6_diy1_b=narant/S1/002_narant 6_diy2_b=narant/S2/002_narant 6_diy1_b=narant/S3/002_narant 6_diy2_b=narant/S1/003_narant 6_diy1_b=narant/S2/003_narant 6_diy2_b=narant/S3/003_narant 5_diy1_a=logos/S1 5_diy2_a=logos/S2 5_diy1_a=logos/S3 5_diy2_b=logos/S1 5_diy1_b=logos/S2 5_diy2_b=logos/S3",