Posted on

There is more than enough about Galton Board, but the code/interactive version is almost like an oasis in the desert! So in my spare time I sat down and created something like this:

Note: The “Matter” physics engine is really cool! :-)

To change the initial randomness, you can play with the following functions and observe :-)

function addPrt() {
    let spcY = height / (rws + 7);
    let rndX = width / 2 + random(-0.02 * width, 0.02 * width);
    prts.push(new Prt(rndX, spcY / 2, 0.01 * height));
    pc++;
}

function addPrts(spcY) {
    for (let i = 0; i < maxPc; i++) {
        let rndX = width / 2 + random(-0.02 * width, 0.02 * width);
        prts.push(new Prt(rndX, spcY / 2, 0.01 * height));
        pc++;
    }
}