munificent / hauberk

A web-based roguelike written in Dart.
http://munificent.github.io/hauberk/
Other
2k stars 200 forks source link

RNG #56

Closed stychu closed 3 years ago

stychu commented 3 years ago

Hello there, how does rng.oneIn(x) work exactly? Could some1 describe it?

Mudshovel commented 3 years ago

Hey there,

It's documented here => https://github.com/munificent/piecemeal/blob/master/lib/src/rng.dart

Apart from that, can't help much =)

munificent commented 3 years ago

@Mudshovel is right. More specifically: https://github.com/munificent/piecemeal/blob/master/lib/src/rng.dart#L95

It returns true 1/x of the time. So oneIn(3) returns true a third of the time and false otherwise.