feat: add combination search workflow
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { generateCombinationCandidates } from './index.ts';
|
||||
|
||||
const cards = [
|
||||
{ id: 'a-1', characterId: 'a', score: 10 },
|
||||
{ id: 'a-2', characterId: 'a', score: 20 },
|
||||
{ id: 'b-1', characterId: 'b', score: 30 },
|
||||
{ id: 'c-1', characterId: 'c', score: 40 }
|
||||
];
|
||||
|
||||
test('고정 카드를 유지하고 같은 멤버의 이격 카드를 제외한다', () => {
|
||||
const result = generateCombinationCandidates([cards[0]], cards, 3, (card) => card.score, 20);
|
||||
assert.equal(result.length, 1);
|
||||
assert.deepEqual(result[0].map((card) => card.id).sort(), ['a-1', 'b-1', 'c-1']);
|
||||
});
|
||||
|
||||
test('빔 너비만큼 점수가 높은 조합을 남긴다', () => {
|
||||
const result = generateCombinationCandidates([], cards, 2, (card) => card.score, 2);
|
||||
assert.equal(result.length, 2);
|
||||
assert.deepEqual(result[0].map((card) => card.id).sort(), ['b-1', 'c-1']);
|
||||
});
|
||||
Reference in New Issue
Block a user