A Simulation with Real Numbers
π― Model something from your Physics or Biology syllabus β projectile motion, or a population that grows and crashes.
π‘ The idea behind it
A simulation is a loop that applies a rule to a state, over and over. That is also what a differential equation is, which is why this project makes calculus feel obvious later.
π§± Blocks you will need
variablesforeverchange bypen downif β¦ thenoperators
π¨ Build it
- Projectile: variables vx and vy. Each tick, change x by vx, change y by vy, and change vy by β0.5 for gravity.
- Turn on the pen so the sprite draws its own path. You have just plotted a parabola from first principles.
- Try different launch angles and record the ranges in a list.
- Population version: population = population + (rate Γ population Γ (1 β population/limit)). Run it and watch an S-curve appear.
- Change the rate until the population stops settling and starts oscillating. That is the beginning of chaos, and you found it yourself.
π Make it harder
- Add air resistance proportional to speed and compare the paths.
- Plot two populations, predator and prey, and look for the cycle.
π Bugs you will hit
- Everything flies off the screen instantly: your step size is too large. Divide all the rates by ten.
- The curve looks jagged: you are drawing one point per frame β run several small steps inside each frame.
β¬ Need Scratch itself?
Free from MIT, in a browser or as an offline app that needs no connection at all.