Author | Comment |
Lunchkin Marine Posted: 10 Jun 2004 13:59 GMT Total Posts: 17 | How can I make more than 1 random event happen? Ex.
You choose to wrestle a pig...
You win
You Loose
You tie |
Lunchbox Carrier
Posted: 10 Jun 2004 17:30 GMT Total Posts: 2007 | goto math -> Probability menu (farthest right) and select randInt(. Use this coding: randint(1,4)->X if x=1 goto 1 if x=2 goto 2 if x=3 goto 3 if x=4 goto 4 Lbl 1 You choose to wrestle a pig Lbl 2 You win Lbl 3 You Lose Lbl 4 You die |
Ray Kremer Ultralisk Posted: 10 Jun 2004 22:20 GMT Total Posts: 310 | Why the gotos? Stick the stuff you want to do right after the If lines inbetween a Then and End.
|
Lunchbox Carrier
Posted: 11 Jun 2004 15:08 GMT Total Posts: 2007 | Labels are better if you want to jump to those certain sets of coding later on in the program. |
Ray Kremer Ultralisk Posted: 12 Jun 2004 00:41 GMT Total Posts: 310 | The way you've done it, it wouldn't work right. You'd need to change it to
randint(1,4)->X if x=1 goto 1 if x=2 goto 2 if x=3 goto 3 if x=4 goto 4 Lbl 1 You choose to wrestle a pig Goto 9 Lbl 2 You win Goto 9 Lbl 3 You Lose Goto 9 Lbl 4 You die Lbl 9
It's so much easier to do
randint(1,4)->X if x=1 Then You choose to wrestle a pig End if x=2 Then You win End if x=3 Then You Lose End if x=4 Then You die End
There's no need to go jumping places when you can do what you need to do RIGHT THERE. |
Lunchbox Carrier
Posted: 13 Jun 2004 09:36 GMT Total Posts: 2007 | actually, there is. WHat if you wanted to jump to those blocks of code from somewhere else in the prog w/out using the randint( part? then my idea works best. Also, i personally dont like If...Then...End statements on the 83+ cause i always wind up putting the end in the wrong place. |
Ray Kremer Ultralisk Posted: 14 Jun 2004 01:32 GMT Total Posts: 310 | >WHat if you wanted to jump to those blocks of code from somewhere else >in the prog w/out using the randint( part? then my idea works best.
And if you have no need of jumping to those bits of code from elsewhere? That's right. Your version has no advantage and needlessly complicates things.
>Also, i personally dont like If...Then...End statements on the 83+ >cause i always wind up putting the end in the wrong place.
Well now, that's your problem, isn't it? Don't project it onto other people. |
dysfunction Goliath Posted: 14 Jun 2004 09:05 GMT Total Posts: 122 | If/Then/Else/End is very necessary if you want to do any programming worthwhile in TI-Basic.
And...
\\You choose to wrestle a pig. RandInt(1,3)->A If A=1 Disp "YOU WIN!" If A=2 Disp "YOU LOSE!" If A=3 Disp "YOU TIE!"
You only need If, no Then or End, if there is only one command following that If. Btw, Lbl/Goto is VERY slow, because it forces the assembling subroutine to search every line of code for the Lbl. For infinite program loops, always use:
Repeat 0 (While 1 works just as well) \\code to be repeated End
[Edited by dysfunction on 14-Jun-04 18:07] |
Lunchbox Carrier
Posted: 14 Jun 2004 21:32 GMT Total Posts: 2007 | No need to attack me, Ray. i just think lbl/goto is better. also, lbl/goto allows for cycling which saves space in your mem and wear on your buttons. |
allynfolksjr Administrator
Posted: 15 Jun 2004 07:21 GMT Total Posts: 1892 | Wear on buttons? Um... If/then and/or lbl/goto neither use buttons to operate....
But In certain situations, it can save RAM however.... |
Lunchbox Carrier
Posted: 15 Jun 2004 15:39 GMT Total Posts: 2007 | Whatever, you know what i meant... just saves RAM space. |
Ray Kremer Ultralisk Posted: 15 Jun 2004 22:50 GMT Total Posts: 310 | As allynfolksjr said, only in certain situtations. It really depends on the code as to what methods are best. You can't say Gotos are better in all situations any more than you can say If/Thens are better in all situations. |
Lunchbox Carrier
Posted: 17 Jun 2004 14:22 GMT Total Posts: 2007 | I didn't say it was ALWAYS better. |