Hello,
I am an educator who has been using GlowScript to conduct various educational programs with high school students and teachers.
I've been using GlowScript for eight years, and while I've continued teaching with the hope that this issue might be fixed someday, I am now writing a related textbook and wanted to ask about this matter.
In standard Python, when using the randint function, randint(a, b) generates an integer n such that a ≤ n ≤ b.
However, in GlowScript, it seems that randint(a, b) generates an n such that a < n ≤ b, which is significantly inconsistent with Python's usage. I'm curious if there is any rational reason for using this range.
(I thought perhaps it's because GlowScript uses JavaScript functions, but even in JavaScript, there doesn't seem to be such an unusual range as a < n ≤ b.)
Thank you in advance for your assistance.
I apologize for the confusion earlier. Upon further investigation, I found that the randint()
function in the GlowScript environment works correctly within positive ranges. However, the issue arises when negative numbers are included in the range. For example, the following code should logically result in the box either moving to the left, staying in place, or moving to the right. However, when I run it, the box only moves to the right. Could you provide any insights or solutions regarding this behavior?
import random b = box() while True: rate(10) b.pos.x = b.pos.x + random.randint(-1,1)
Thank you for your time and assistance.