test: 10-round double timeout simulation — draw, equal HP, no loops
Simulates both bots timing out every round for 10 rounds. Verifies zero damage per round, HP unchanged at 200, draw outcome. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9346b6b260
commit
ffad432e5b
@@ -242,3 +242,36 @@ describe('challenge type rotation', () => {
|
|||||||
expect(usedTypes.has(remaining.type)).toBe(false)
|
expect(usedTypes.has(remaining.type)).toBe(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('10-round double timeout simulation', () => {
|
||||||
|
it('both bots timeout every round: fight ends as draw, equal HP, no infinite loop', () => {
|
||||||
|
const STARTING_HP = 200
|
||||||
|
const MAX_ROUNDS = 10
|
||||||
|
let hpA = STARTING_HP
|
||||||
|
let hpB = STARTING_HP
|
||||||
|
let winnerId: string | null = null
|
||||||
|
|
||||||
|
for (let round = 1; round <= MAX_ROUNDS; round++) {
|
||||||
|
const ch = makeChallenge()
|
||||||
|
const result = scoreRound(
|
||||||
|
ch, botA, botB,
|
||||||
|
resp(null, 8000, { timedOut: true }),
|
||||||
|
resp(null, 8000, { timedOut: true }),
|
||||||
|
null, 0, 0,
|
||||||
|
)
|
||||||
|
// Both timeout → zero damage, zero scores, no winner
|
||||||
|
expect(result.winnerId).toBeNull()
|
||||||
|
expect(result.botADamage).toBe(0)
|
||||||
|
expect(result.botBDamage).toBe(0)
|
||||||
|
hpA -= result.botBDamage // damage TO A = B's damage output
|
||||||
|
hpB -= result.botADamage // damage TO B = A's damage output
|
||||||
|
}
|
||||||
|
|
||||||
|
// After 10 rounds of double timeout: HP unchanged, draw
|
||||||
|
expect(hpA).toBe(STARTING_HP)
|
||||||
|
expect(hpB).toBe(STARTING_HP)
|
||||||
|
// Determine winner: equal HP → null (draw)
|
||||||
|
winnerId = hpA > hpB ? 'a1' : hpB > hpA ? 'b1' : null
|
||||||
|
expect(winnerId).toBeNull()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user