fuzzyworld

explodorama / files / test / balance.test.ts

balance.test.ts

1.0 KB · history · blame

1import { describe, expect, it } from 'vitest'
2import { canSurvive, makeBot, SKILLS } from '../tools/balance/bot'
3import { playRun } from '../tools/balance/play'
4import { board, v } from './helpers'
5
6describe('the balance lab', () => {
7 it('the Careful bot clears the first levels of a seed without stalling', () => {
8 const r = playRun(1, makeBot(1), () => {}, 3)
9 expect(r.levelsCleared).toBe(3)
10 expect(r.stalled).toBe(false)
11 })
12
13 it('the same seed and bot play the same run', () => {
14 const a = playRun(2, makeBot(2, SKILLS.average), () => {}, 2)
15 const b = playRun(2, makeBot(2, SKILLS.average), () => {}, 2)
16 expect(a).toEqual(b)
17 })
18
19 it('canSurvive sees a dead end in a bomb’s blast', () => {
20 const s = board(`
21 #####
22 #P1.#
23 #####`)
24 s.bombs[0]!.timer = 2
25 expect(canSurvive(s, 3)).toBe(false)
26 const open = board(`
27 ######
28 #P..1#
29 ######`)
30 open.player = v(2, 1)
31 open.bombs[0]!.timer = 2
32 expect(canSurvive(open, 3)).toBe(true)
33 })
34})