An interactive simulation of the Galton Board built with HTML5 Canvas and vanilla JavaScript. It demonstrates the binomial distribution and the Gaussian (bell) curve in a highly visual and interactive way. ๐
- โ๏ธ Realistic Physics: Elastic bounces and falling mechanics controlled by gravity and friction.
- ๐ฑ Multi-drop: Choose to drop 1, 5, 10, 50, or 100 balls at once!
- โ๏ธ Adjusted Difficulty: Most of the central buckets grant no points (simulating player attrition), while the outermost buckets offer high rewards.
- ๐งฉ Fully Modular: Code separated into HTML, CSS, and JS for easy maintenance.
- Clone the repository to your local machine.
- Open the
index.htmlfile in any modern web browser. (No local server is required!) - Choose the number of balls you want to drop from the dropdown menu.
- Click the
Dropbutton to let the balls fall through the peg pyramid. - Keep an eye on the Current Balls counter. If it reaches
0, the game is over. โ ๏ธ
Probability dictates that the vast majority of balls will land near the center. In this game, the central buckets have an x0 multiplier, meaning you will lose any ball that lands there.
Your goal is to get lucky and have balls bounce towards the edges ๐ (which hold the x2, x5, and x10 multipliers) to recover and increase your total ball count!
All the main logic and variables can be found in script.js inside the GAME_CONFIG object.
You can easily tweak the following to create your own experience:
initialBalls: Starting balls for the player.pegRows: Number of peg rows in the pyramid.bounceDampingandgravity: Bounce and falling physics.- Multipliers in the
drawBuckets()andfinalizeBall()functions.
Haddy187