Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating a 6-faced die in Ada-2005

Tags:

ada

I have very definitively come across the 'simulating a 6-faced die' (which produces a random integer between 1 and 6, all outcomes are equally probable) in Java, Python, Ruby and Bash. However, I am yet to see a similar program in Ada. Has anyone come across one?

like image 785
Arkapravo Avatar asked Jan 19 '26 08:01

Arkapravo


1 Answers

See Random Number Generation (LRM A.5.2) for packages to assist with doing this. Either Ada.Numerics.Float_Random for uniform random number generation (range 0.0 .. 1.0) which you can then scale on your own, or instantiate Ada.Numerics.Discrete_Random with a suitable (sub)type (works for d4, d10, d12, and d20s as well!).

like image 97
Marc C Avatar answered Jan 21 '26 07:01

Marc C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!