devicefuture / atto

The new BASIC computer that runs in your browser!
https://atto.devicefuture.org
MIT License
47 stars 8 forks source link

"random" in "draw" works incorrectly #42

Closed ghost closed 1 year ago

ghost commented 1 year ago

It looks like the old location is also randomized, but it shouldn't be. If you type: 10 for count=1 to 100 20 draw random*500,random*500 30 next The lines will NOT be connected to each other. But if after that you type: 11 x=random*500 12 y=random*500 20 draw x,y renum It will work correctly. atto devtools 3 atto devtools 4

James-Livesey commented 1 year ago

Just fixed this, so it should work now! Basically, the arguments passed to commands such as draw ended up getting evaluated multiple times (which is a problem when expressions containing random always change), so I made sure they only get evaluated once. There were a bunch of other commands that are affected by this issues as well, so I fixed all of them, too.

Test case program:

5 cls
10 for count=1 to 10
11 x=random*500
12 y=random*500
20 draw random*500, random*500
30 next
40 goto 40

Thanks for reporting the issue! The atto.devicefuture.org site should update shortly, and you might need to clear your browser cache.

James-Livesey commented 1 year ago

(Also — not sure if it was intentional on your part — but I appreciate how the bad and good test cases are coloured red and green respectively 😉)

ghost commented 1 year ago

Yes, if I don't do a "hard reset", the bug will still weirdly be there.