Quote: "I recently got Dark Basic,"
Hello, and welcome! Should have said that first.
For random values in a certain range, the high value of the range is the the value inside the () plus the outside value. The low value for the range is the outside value.
So, for a function call like rnd(5), the high value is 5 plus an outside value of 0. The low range is the implied outside value of 0. So the range of rnd(5) is 0 to 5 .
How about something like rnd(10)-4 ?
The high value is 10 plus the outside value of -4 :
10 + -4 = 6
The low value is the outside value :
-4
So the range of random values is -4 to 6 .
Put it in reverse to solve for the value in the (). Say you want the high range to be 6 and the low range to -4 but you don't know what value to put in rnd(). Start with what you know:
high value = inside () + outside ()
6 = x + -4
a little algebra to juggle things around:
x = 6 + 4
x = 10
So the function becomes rnd(10)-4
How can you apply this to return the values you want of 2 to 7? If you need help you can look at the solution in the code box below:
rnd(5)+2
7 = x + 2
x = 7 - 2
x = 5
the high value is 5 plus +2 = 7
the low value is +2 = 2
And Obese was saying you don't need the conditional if then tests in
rem loop through B and list the traits
for n=1 to B
Rem random one personality point
A = rnd(3)
if A = 0 then print p$(0)
if A = 1 then print p$(1)
if A = 2 then print p$(2)
if A = 3 then print p$(3)
next n
It would be much simpler to just:
rem loop through B and list the traits
for n=1 to B
Rem random one personality point
A = rnd(3)
print p$(A)
next n
or even
rem loop through B and list the traits
for n=1 to B
Rem random one personality point
print p$(rnd(3))
next n
Enjoy your day.