feat: improve analysis and release v1.0.2

This commit is contained in:
2026-08-19 13:47:49 +09:00
parent 488d652e61
commit e259f82b69
30 changed files with 1222 additions and 205 deletions
+56 -1
View File
@@ -1,6 +1,12 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { generateCombinationCandidates, resolveCandidateAwakening } from './index.ts';
import {
combinationSearchLimits,
generateAnchoredCombinationCandidates,
generateCombinationCandidates,
resolveCandidateAwakening,
selectMemberDiverseCandidates
} from './index.ts';
const cards = [
{ id: 'a-1', characterId: 'a', score: 10 },
@@ -44,3 +50,52 @@ test('보유한 자동 후보는 설정값보다 실제 개화가 높으면 실
assert.equal(resolveCandidateAwakening(4, true, 2), 4);
assert.equal(resolveCandidateAwakening(2, false, 5), 2);
});
test('빈 멤버 수에 비례해 선별 및 정밀 분석 후보 수를 늘린다', () => {
assert.deepEqual(combinationSearchLimits(4), {
openSlots: 1,
screeningLimit: 5_000,
baseExactFinalistLimit: 56,
alternativeExactFinalistLimit: 56
});
assert.deepEqual(combinationSearchLimits(3), {
openSlots: 2,
screeningLimit: 10_000,
baseExactFinalistLimit: 112,
alternativeExactFinalistLimit: 112
});
assert.deepEqual(combinationSearchLimits(0), {
openSlots: 5,
screeningLimit: 25_000,
baseExactFinalistLimit: 280,
alternativeExactFinalistLimit: 280
});
});
test('각 자동 후보를 임시 축으로 삼은 조합을 선별한다', () => {
const anchoredCards = [
{ id: 'a', characterId: 'a', score: 100 },
{ id: 'b', characterId: 'b', score: 90 },
{ id: 'c', characterId: 'c', score: 80 },
{ id: 'd', characterId: 'd', score: 1 }
];
const result = generateAnchoredCombinationCandidates(
[],
anchoredCards,
2,
[{ scoreCard: (card) => card.score }],
1
);
assert.ok(result.some((combination) => combination.some((card) => card.id === 'd')));
});
test('정밀 분석 후보에 각 카드의 최고 대표 조합을 남긴다', () => {
const candidates = [
{ cards: [{ id: 'a', characterId: 'a' }, { id: 'b', characterId: 'b' }], score: 100 },
{ cards: [{ id: 'a', characterId: 'a' }, { id: 'c', characterId: 'c' }], score: 90 },
{ cards: [{ id: 'd', characterId: 'd' }, { id: 'e', characterId: 'e' }], score: 20 }
];
const result = selectMemberDiverseCandidates(candidates, (candidate) => candidate.cards, (candidate) => candidate.score, [], 10);
assert.equal(result.length, 3);
assert.ok(result.some((candidate) => candidate.cards.some((card) => card.id === 'e')));
});