diff options
Diffstat (limited to 'src/helpers.ts')
| -rw-r--r-- | src/helpers.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/helpers.ts b/src/helpers.ts index 9bb1eac..a867b1e 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -11,3 +11,8 @@ export function random(p: number): boolean { if (p < 0 || p > 1) throw Error("Wrong probability - " + p) return Math.random() < p; } +export function randomInteger(min: number, max: number) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} |
