random number generator
Moderator: MaxCoderz Staff
-
- New Member
- Posts: 2
- Joined: Thu 10 Nov, 2005 11:01 pm
random number generator
i'm trying to make a random # generator to use in some of the RPGs i play. I'm justing using the basic programming on the calc. I'm having trouble getting it to repeat the number of times i want
ex. i want a d6 rolled 8 times, so when i bring up the program i type in how many times i want it rolled and itcomes up w/ a number
but the problem is that i can't figur out how to do it so it just does the operation a bunch of times and adds it together
this is what i have so far
:clrhome
:prompt A
:randint(1,6)=B
i've tryed various steps after this to make it do what i want but none of them work, they just send it into a continual loop
thx-in advance
ex. i want a d6 rolled 8 times, so when i bring up the program i type in how many times i want it rolled and itcomes up w/ a number
but the problem is that i can't figur out how to do it so it just does the operation a bunch of times and adds it together
this is what i have so far
:clrhome
:prompt A
:randint(1,6)=B
i've tryed various steps after this to make it do what i want but none of them work, they just send it into a continual loop
thx-in advance
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
Code: Select all
Prompt A
For(B,0,A)
randInt(1,6)->C
Disp C
End
So if you want it to add the numbers together you would do this
or if you mean the one that rolls the most like it rolls six times and it rolled a 1,2,3,3,5,3 and you want to show just the one that was rolled the most you would do this.
Code: Select all
delvar B
prompt A
For(X,1,A
B+randInt(1,6->B
End
Disp B
Code: Select all
prompt A
Delvar L1
6->dim(L1
For(X,1,A
randInt(1,6
1+L1(Ans->L1(Ans
End
Disp L1
How about
It rolls a d6 8 times, and stores that 8 values in L1, and to add them
So, all together
That prompts you for how many dice you are rolling, and how many sides, rolls that many dice, displays what you rolled in a little scrollable list, then when you press enter it adds them and gives you the value it added to.
Code: Select all
randInt(1,6,8->L1
Code: Select all
sum(L1
Code: Select all
Input "How many:",A
Input "d what:",B
randInt(1,B,A->L1
Pause L1
sum(L1->C
Disp C
Shaun
No, Merthsoft is correct. At least that is how it works on my 83+.
To just get the random numbers added up, use this expression:
To just get the random numbers added up, use this expression:
Code: Select all
sum(randInt(1,6,8
Or:
in this case...
with asking:
while A is the kind of dice and B is the amount...
Code: Select all
randInt(6,48
with asking:
Code: Select all
Prompt A,B (or input stuff)
randInt(B,AB
Revolution Software
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
Unfortunately, that does not end up with the same distribution of numbers. No, I believe sum(randInt(1,6,6 is the fastest you can get simply because it's so short. -sum(int(-6rand(6 is equally short I believe.NanoWar wrote:Or:Code: Select all
randInt(6,48
Run each method a bunch of times in a for loop with the same conditions, see which loop finishes faster.how would you know which method is faster?
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
http://www.unitedti.org/index.php?showtopic=3900
check towards the bottom of the page, supergooses' post.
check towards the bottom of the page, supergooses' post.
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact: