feat: add answer confidence differential as scoring factor
When both bots are correct, the one with higher checkAnswer confidence (exact match 1.0 vs fuzzy match 0.8) gets up to +1.0 bonus points. This rewards precise answers over approximate ones, adding another competitive dimension beyond pure speed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
cb8a45cfb3
commit
c6c792dd9e
@@ -218,6 +218,25 @@ describe('scoreRound', () => {
|
|||||||
expect(typeof result.narration).toBe('string')
|
expect(typeof result.narration).toBe('string')
|
||||||
expect(result.narration.length).toBeGreaterThan(10)
|
expect(result.narration.length).toBeGreaterThan(10)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('answer confidence gives bonus — exact match (1.0) beats fuzzy match (0.8)', () => {
|
||||||
|
// Use answers where one answer is a substring of another
|
||||||
|
// "satoshi" against ["satoshi nakamoto"] scores 0.8 (containment)
|
||||||
|
// "satoshi nakamoto" against ["satoshi nakamoto"] scores 1.0 (exact)
|
||||||
|
const challenge = makeChallenge({ answers: ['satoshi nakamoto'] })
|
||||||
|
|
||||||
|
// Both answer at equal speed, but A has exact match, B has fuzzy
|
||||||
|
const result = scoreRound(
|
||||||
|
challenge, botA, botB,
|
||||||
|
makeResponse('satoshi nakamoto', 500), // exact → 1.0
|
||||||
|
makeResponse('nakamoto', 500), // contained → 0.8
|
||||||
|
null, 0, 0,
|
||||||
|
)
|
||||||
|
|
||||||
|
// A should score higher due to confidence differential
|
||||||
|
expect(result.botAScore).toBeGreaterThan(result.botBScore)
|
||||||
|
expect(result.winnerId).toBe('a1')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('calculateElo', () => {
|
describe('calculateElo', () => {
|
||||||
|
|||||||
@@ -131,12 +131,15 @@ export function scoreRound(
|
|||||||
const confA = Math.min(correctA, 1)
|
const confA = Math.min(correctA, 1)
|
||||||
const confB = Math.min(correctB, 1)
|
const confB = Math.min(correctB, 1)
|
||||||
|
|
||||||
|
// Confidence differential: exact match (1.0) vs fuzzy (0.8) gives up to +1.0 bonus
|
||||||
|
const confDiff = confA - confB
|
||||||
|
|
||||||
if (aFaster) {
|
if (aFaster) {
|
||||||
scoreA = FACTUAL_FASTER_BASE + (1 - speedRatio) * SPEED_ADVANTAGE_MULTIPLIER + confA
|
scoreA = FACTUAL_FASTER_BASE + (1 - speedRatio) * SPEED_ADVANTAGE_MULTIPLIER + confA + Math.max(0, confDiff)
|
||||||
scoreB = FACTUAL_SLOWER_BASE + speedRatio * SPEED_RATIO_MULTIPLIER + confB * CONFIDENCE_BONUS
|
scoreB = FACTUAL_SLOWER_BASE + speedRatio * SPEED_RATIO_MULTIPLIER + confB * CONFIDENCE_BONUS + Math.max(0, -confDiff)
|
||||||
} else {
|
} else {
|
||||||
scoreA = FACTUAL_SLOWER_BASE + speedRatio * SPEED_RATIO_MULTIPLIER + confA * CONFIDENCE_BONUS
|
scoreA = FACTUAL_SLOWER_BASE + speedRatio * SPEED_RATIO_MULTIPLIER + confA * CONFIDENCE_BONUS + Math.max(0, confDiff)
|
||||||
scoreB = FACTUAL_FASTER_BASE + (1 - speedRatio) * SPEED_ADVANTAGE_MULTIPLIER + confB
|
scoreB = FACTUAL_FASTER_BASE + (1 - speedRatio) * SPEED_ADVANTAGE_MULTIPLIER + confB + Math.max(0, -confDiff)
|
||||||
}
|
}
|
||||||
} else if (correctA > 0 && correctB === 0) {
|
} else if (correctA > 0 && correctB === 0) {
|
||||||
scoreA = ONE_CORRECT_WINNER_BASE + correctA * CONFIDENCE_BONUS
|
scoreA = ONE_CORRECT_WINNER_BASE + correctA * CONFIDENCE_BONUS
|
||||||
|
|||||||
Reference in New Issue
Block a user