? operator doesn't choose new direction uniformly at random. more likely to go "down" than "right"

Bug #1915376 reported by David Rutter on 2021-02-11
This bug affects 1 person
Affects Status Importance Assigned to Milestone
jsFunge IDE

Bug Description

As a test case for ? giving uniform direction selection behavior, this test program should generate each type of letter about equally often (e.g. close to 13 times):

7>!@v >?v
3 :v?<
9,-"" ""
4+1AC GT
+,,"" ""
>^^<< <<

Right now it consistently outputs only about 6 Ts.

Revision history for this message
David Rutter (quintopia) wrote :

I looked at the code for handling '?'. The bug is in the line:

randint = ((Math.round(Math.random()*3)));

This will generate the number 1 or 2 twice as often as 0 or 3. It should change to:

randint = ((Math.floor(Math.random()*4)));

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers