|19BII Program Question|
Message #1 Posted by Hans van der Drift on 28 Jan 2007, 10:02 p.m.
I would like to ask for some help. I have some general knowledge of the solver and formulas but I am stumped on how (or if) to create a simple dice rolling equation.
I am trying to create a solver function that will re-create the following.
NUM DICE? = D
HIT MIN? = H
Number of hits = X
So if I needed to recreate the rolling of 48 dice and show how many results are 5 and 6 cumulatively. or 32 dice and how many results are 4, 5 and 6 cumulatively.
I saw a post from a guy that has done the on a TI-82. He used this formula.
--clear the screen
--the variable x gets reset to 0, x will hold the # of successful hits
Input ("Num Dice? ", D)
--Prompts for # of dice to roll, stores the value in variable D
Input ("Hit Min? ", H)
--Prompts for Minimum number needed for a succesful hit, usually 4,5, or 6, and stores in Variable H)
--This is a loop, the Variable I is our incrememted by 1 each time through until it is equal to D, which is the # of dice rolls
If ((int (rand*6+1)>=H)
--if the randomly generated number of 1-6 is greater than variable H, your minimum hit #, then...
--X, your hit count variable, gets incremented by 1
--end the loop
--print out the number of hits
REPLACE THIS TEXT WITH THE QUOTE