Range for RANDOM; AND, OR

26 views
Skip to first unread message

holden HK

unread,
Apr 18, 2014, 10:01:05 PM4/18/14
to starlo...@googlegroups.com
How to define a range for RANDOM from negative to positive numbers? For example, in Scratch there is 'PICK RANDOM (n) TO (n)', which makes it very easy to define, e.g. 'PICK RANDOM (-50) TO (50)'
Also, how to emulate AND and OR operators (I can't see them in Math section)?

Daniel Wendel

unread,
Apr 18, 2014, 10:14:26 PM4/18/14
to starlo...@googlegroups.com
AND and OR are in Logic for us.

RANDOM gives a number between 1 and whatever you give it. So to emulate PICK RANDOM (-50) TO (50) you would do:

(51) - (RANDOM (101))

It's been a struggle balancing ease of use with keeping the overall number of blocks low. But maybe we need to get rid of RANDOM and replace it with PICK RANDOM for StarLogo Nova. What do you think?

--Daniel


On Fri, Apr 18, 2014 at 10:01 PM, holden HK <hold...@gmail.com> wrote:
How to define a range for RANDOM from negative to positive numbers? For example, in Scratch there is 'PICK RANDOM (n) TO (n)', which makes it very easy to define, e.g. 'PICK RANDOM (-50) TO (50)'
Also, how to emulate AND and OR operators (I can't see them in Math section)?

--
You received this message because you are subscribed to the Google Groups "StarLogo TNG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to starlogo-tng...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

holden HK

unread,
Apr 18, 2014, 10:42:04 PM4/18/14
to starlo...@googlegroups.com
Thanks for a quick explanation.
After the confusion with YIELD I had second thoughts about what should or should not be there in SL TNG.
First, you're right - I should have checked the bubble over YIELD before I started asking. I didn't do it because I thought YIELD meant 'produce' (something like HATCH) in this context, and when I explained the whole thing to my 8-year-old son, he asked me: 'Doesn't "yield" mean "give way", or simply "wait", like when you yield at the intersection?' Apparently, there is nothing wrong with the name of the function, which brought me to the next idea...
Second, if the way that RANDOM function in SL TNG is built is the way most programming language use it (I don't know this, but I'm sure you do), it should be preserved. The sooner the kids learn the semantics and syntax of programming languages the better, in my opinion.
So, the third thing is that it's not necessary that convenience should trump the accepted practices (as long as they ARE accepted practices). Of course WAIT (n) SEC or PICK RANDOM would be more convenient, but is it the way computers are programmed?
And I can't agree more with you that SL TNG should involve the community much more. It has at least as much potential as Scratch, and I was surprised that such an excellent tool is so (relatively) little known. It deserves much, much more than that.

Ian
Reply all
Reply to author
Forward
0 new messages