vendredi 16 juillet 2021

What does a random Walker favour moving from up and to the left?

Has anyone tried this tutorial on the "The Nature of Code" site ? https://natureofcode.com/book/introduction/

Check out this code where a step is a random number from -1 to 1.,

void step() {
    //[full] Yields any floating point number between -1.0 and 1.0
    float stepx = random(-1, 1);
    float stepy = random(-1, 1);
    //[end]
    x += stepx;
    y += stepy;

Why does the randomness always favour a very specific path up and to the left ? I don't get it.




Aucun commentaire:

Enregistrer un commentaire