sim
This commit is contained in:
parent
746d218eda
commit
e590baf28d
44 changed files with 8308 additions and 0 deletions
18
sim/test/odds.test.ts
Normal file
18
sim/test/odds.test.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue