Files
HolodoriCalc/scripts/validate-sus-score-formulas.mjs
T
dal4segno e688036d11
Publish GitHub Pages output / publish (push) Successful in 54s
fix: calculate chart scores with song formulas and hidden note weights
2026-09-06 21:51:42 +09:00

22 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import path from 'node:path';
import { susScoreWeight } from './sus-score-weight.mjs';
const record = JSON.parse(await readFile(new URL('../docs/research/sus-score-formulas.json', import.meta.url), 'utf8'));
const directory = process.argv[2] ?? 'data/raw/sus';
for (const row of [...record.validationCharts, ...record.charts]) {
const bytes = await readFile(path.join(directory, `chart_${row.songId}_${row.difficulty}.sus`));
assert.equal(createHash('sha256').update(bytes).digest('hex'), row.susSha256);
const actual = susScoreWeight(bytes.toString('utf8'));
assert.equal(actual.songId, row.songId);
assert.equal(actual.perfectNoteWeight, row.perfectNoteWeight, `${row.songId}.${row.difficulty}`);
if (row.counts) {
assert.deepEqual(actual.counts, row.counts);
assert.equal(actual.invisibleRelayCount, row.invisibleRelayCount);
assert.equal(actual.bezierPointCount, row.bezierPointCount);
}
}
console.log(`${record.validationCharts.length}개 기존 분모와 ${record.charts.length}개 신규 SUS 분모를 재현했습니다.`);