3 ms·
If anyone, like me, is wondering if the bug solution is correct, here's the original documentation for the RND() function in Applesoft BASIC language (page 102)
by ojosilva 9y ago
If anyone, like me, is wondering if the bug solution is correct, here's the original documentation for the RND() function in Applesoft BASIC language (page 102):
https://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Software/Languages/Applesoft%20BASIC/Manuals/Applesoft%20II%20BASIC%20Programming%20Reference%20Manual.pdf https://mirrors.apple2.org.za/Apple%20II%20Documentation%20P...
Which says:
RND(aexpr)
Returns a random real number greater than or equal to 0 and less than 1.
Which is pretty much the standard for a random function in many other computer languages through history, ie. Python's random.random(), JS Math.random(), ... There are other, more creative versions of the function, like Perl's and Ruby's rand(max), which differ slightly by allowing the user to set the max number.
But this other reference link, which presumably takes its information from the back of another book could have led the Airwolf programmer to make the mistake:
http://www.landsnail.com/a2ref.htm http://www.landsnail.com/a2ref.htm
It says the generated number is between 0 and 1, without mention to 1 being exclusive. I believe this a common confusion when it comes to RND() usage.
- Johnny555 9y agoEven if it were 0.0 to 1.0 inclusive there'd still be a bug in the code since there's a very slim chance of getting a 1.000000 from the RNG, so in that buggy code, 'F' would still almost never be selected. For that reason, a floating point random number from 0 to 1.0000000 inclusive would be hard to work with.
- smitherfield 9y agoAnother way to fix the bug would've been INT(RND(1) * 15 + .5) which is equivalent to rounding to the nearest integer* instead of truncating. *If positive, which RND's return value must be.
- rzzzt 9y agoThe labyrinth-printing example for the C64 also uses this: https://10print.org/ https://10print.org/