You have now seen how to make a Monte Carlo simulation of three different stochastic differential equations. The first is Brownian motion. The second and third are Geometric Brownian motion. These will simulate stock prices, first without jumps, then with jumps. You can use the same code for the stock prices, making the jump size zero if you don’t want any jumps. Let’s code it.
You need particles to move, so code a Particle class with a position (x, y) and a way to Move. To avoid busting through the sides of the bag, specify the bag’s edges and its size. When a particle is high enough to escape from the bag, it’s done and stops moving: