random number generator

Got a brilliant program idea? Let us know!

Moderator: MaxCoderz Staff

Post Reply
bandnerd1892
New Member
Posts: 2
Joined: Thu 10 Nov, 2005 11:01 pm

random number generator

Post by bandnerd1892 »

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
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Code: Select all

Prompt A
For(B,0,A)
randInt(1,6)->C
Disp C
End
Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

So if you want it to add the numbers together you would do this

Code: Select all

delvar B
prompt A
For(X,1,A
B+randInt(1,6->B
End
Disp B
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

prompt A
Delvar L1
6->dim(L1
For(X,1,A
randInt(1,6
1+L1(Ans->L1(Ans
End
Disp L1
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

How about

Code: Select all

randInt(1,6,8->L1
It rolls a d6 8 times, and stores that 8 values in L1, and to add them

Code: Select all

sum(L1
So, all together

Code: Select all

Input "How many:",A
Input "d what:",B
randInt(1,B,A->L1
Pause L1
sum(L1->C
Disp C
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.
Shaun
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

I could've sworn that the third condition was the number it skips by, randInt(start,end,jump by
E.X. randInt(1,3,2 would return a 1 or a 3 so it skips by two and will not hit #2.
User avatar
axcho
New Member
Posts: 53
Joined: Thu 20 Oct, 2005 5:44 pm
Contact:

Post by axcho »

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:

Code: Select all

sum(randInt(1,6,8
User avatar
NanoWar
Extreme Poster
Posts: 365
Joined: Fri 17 Dec, 2004 6:39 pm
Location: #$&"%§!
Contact:

Post by NanoWar »

Or:

Code: Select all

randInt(6,48
in this case... :)

with asking:

Code: Select all

Prompt A,B (or input stuff)
randInt(B,AB
while A is the kind of dice and B is the amount...
Revolution Software
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Nace nano :P, but does he still need this? I haven't seen him around...
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

how would you know which method is faster?
Image Image Image
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

NanoWar wrote:Or:

Code: Select all

randInt(6,48
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.
how would you know which method is faster?
Run each method a bunch of times in a for loop with the same conditions, see which loop finishes faster.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Or you can use a 84 model and set the time up with the seconds.
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

It's bound to take less than a second.
Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

http://www.unitedti.org/index.php?showtopic=3900
check towards the bottom of the page, supergooses' post.
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

threefingeredguy wrote:It's bound to take less than a second.
That's why you put it in a for loop. If it takes .017 of a second, then when you loop it 1000 times it will take 17 seconds.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

I tested it. The sum(randInt(1,6,6 is faster than sum(int(-6rand(6 .
In Memory of the Maxcoderz Trophy Image
Post Reply