import assert from 'node:assert/strict'; import { test } from 'node:test'; import { winChance } from '../src/odds.ts'; test('equal Cores are a coin flip and odds are complementary', () => { for (let a = 1; a <= 8; a++) { assert.ok(Math.abs(winChance(a, a) - 0.5) < 1e-12); for (let d = 1; d <= 8; d++) assert.ok(Math.abs(winChance(a, d) + winChance(d, a) - 1) < 1e-12); } }); test('matches the table in rules.md', () => { assert.equal(Math.round(100 * winChance(2, 1)), 90); assert.equal(Math.round(100 * winChance(3, 4)), 21); assert.equal(Math.round(100 * winChance(2, 4)), 4); assert.equal(Math.round(100 * winChance(6, 4)), 91); assert.equal(Math.round(100 * winChance(8, 7)), 71); });