06-09-2018, 03:05 PM

One way to simulate a pair of dice being thrown is to generate two random integers between 1 through 6. The integers are either shown as a pair or vector of integers. For calculators that do not have a list capacity or want a more compact representation, the program for the HP 32S II (which can easily apply almost to any other programming calculator), in the format A.0B, where A is one die and B is the other. For example, 3.06 represents a 3 and a 6 being thrown.

The formula would be: RandInt(1,6) + RandInt(1,6)/100

We can also use the Unicode representation of dice.

Unicode/Decimal/Hexadecimal

⚀ 9856 2680

⚁ 9857 2681

⚂ 9858 2682

⚃ 9859 2683

⚄ 9860 2684

⚅ 9861 2685

Unicode characters need to be in strings. The HP Prime program RDICE returns a list, the roll in compact format, along with the Unicode representation. This is only one of many ways to do it.

An example output of RDICE is {4.02, “⚃”, “⚁”}

HP Prime Program: RDICE

HP 32 SII Program: Dice Generator

Link to post: https://edspi31415.blogspot.com/2018/06/...-dice.html

The formula would be: RandInt(1,6) + RandInt(1,6)/100

We can also use the Unicode representation of dice.

Unicode/Decimal/Hexadecimal

⚀ 9856 2680

⚁ 9857 2681

⚂ 9858 2682

⚃ 9859 2683

⚄ 9860 2684

⚅ 9861 2685

Unicode characters need to be in strings. The HP Prime program RDICE returns a list, the roll in compact format, along with the Unicode representation. This is only one of many ways to do it.

An example output of RDICE is {4.02, “⚃”, “⚁”}

HP Prime Program: RDICE

Code:

EXPORT RDICE()

BEGIN

// rolling dice A.0B

LOCAL A, B, C, D;

A≔RANDINT(1,6); C≔9855+A;

B≔RANDINT(1,6); D≔9855+B;

RETURN {A+B/100, CHAR(C), CHAR(D)};

END;

HP 32 SII Program: Dice Generator

Code:

D01 LBL D

D02 RANDOM

D03 6

D04 *

D05 1

D06 +

D07 IP

D08 1

D09 %

D10 RANDOM

D11 6

D12 *

D13 1

D14 +

D15 IP

D16 +

D17 RTN

Link to post: https://edspi31415.blogspot.com/2018/06/...-dice.html