Simulations

This project consists of a simulation framework and a collection of simulations written in Scala. Examples include reaction diffusion, fractals, snakes, stocks, dice, fluid flow, and many more.

Download this zip file and unzip it. Then in the bin directory run one of commands indicated below.


Reaction Diffusion

bb4-simulator -panel_class com.barrybecker4.simulation.reactiondiffusion.RDSimulator

Simulates a interaction between 2 chemicals in a reaction diffusion simulation. The program is based on an applet by Joakim Linde. There are 2 chemicals that react in complex ways as defined by a non-linear differential equation that cannot be solved analytically. The simulation solves it numerically.

Reaction Diffusion

Henon Phase Explorer

bb4-simulator -panel_class com.barrybecker4.simulation.henonphase.HenonPhaseExplorer

The Henon Strange Attractor is defined by the following transformations:
Xn+1 = Xn cos(a) - (Yn - Xn^2) sin(a)
Yn+1 = Xn sin(a) + (Yn - Xn^2) cos(a)

Henon Phase Explorer

Fractal Explorer

bb4-simulator -panel_class com.barrybecker4.simulation.fractalexplorer.FractalExplorer

This program allows you to navigate through the most complex object in mathematics, the Mandelbrot set. Drag open a bock to zoom, and click the "go back" button to undo the last zoom. When I created my first implementation of this program in turbo pascal in high school, I can remember waiting for hours for the images to generate (on a 640 by 200 pixel screen). Now its almost instantaneous.

Fractal Explorer

Cave Explorer

bb4-simulator -panel_class com.barrybecker4.simulation.cave.CaveExplorer

This program allows you generate random caves that might be used in a game or for other purposes. The technique is described in this article.

Cave Explorer

Conway's Game of Life

bb4-simulator -panel_class com.barrybecker4.simulation.conway.ConwayExplorer

This program allows you to simulate Conway's game of life. Color is used to indicate the age of the particles. Several different rule systems are allowed.

Conway's Game of Life

Snake

bb4-simulator -panel_class com.barrybecker4.simulation.snake.SnakeSimulator

Simulate a living snake. The program uses a spring based model to represent the snake. There is a sinusoidal force function applied to each side to simulate muscular contractions. Directional friction is used to make the snake go forward (as happens with a real snake). Snakes have 4 ways of moving: rectilinear progression, horizontal undulatory progression, sindwinding, and concertina progression (rarely used). I only used the most common gait, horizontal undulatory progression, in this demo, but will probably add the others. You can also change the parameters of this gait to get different behaviors. The snake "learns" to move more efficiently by a process of automated optimization. It uses exactly the optimization code I use for improving the performance of the game programs. I now understand really well how a snake moves. Based on work by Gavin Miller in his 1988 SIGGRAPH paper.

Snake

Dice

bb4-simulator -panel_class com.barrybecker4.simulation.dice.DiceSimulator

This simulator evolved out of looking for a good way to explain probability distributions to my son and his clasmates. This simple program illustrates the different sorts of bell-curve (or gaussian) distributions that can arise as you vary the number of dice and the number of sides that they have.

Dice

Stock Price Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.stock.StockSimulator

This simulation was motivated by the following problem.
You invest $100,000 in a volatile stock. Each year, with equal probability, it either rises 60% or falls by 40%. What would be the expected (mean), median, and mode stock valuations after 100 years?
The moral of the story is Diversify!

Stock Price Simulation

Stock Trading Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.trading.TradingSimulator

This work was requested by a friend. The public version of this project has some trivial generation and trading strategies, but there is a private repo that has proprietary strategies.

Stock Trading Simulation

Habitat Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.habitat.HabitatSimulator

Create and maintain a set of creatures in a self-sustaining habitat. In the future, I would like to add many more attributes to each creature to make the simulation more realistic.

Habitat Simulation

Verhulst Population Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.verhulst.VerhulstSimulator

Chaotic behavior can emerge from using a dynamic logistic population growth model like the one researched by Pierr Verhulst. See Rabbits and Coyotes.

Verhulst Population Simulation

Predator Prey Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.predprey.PredPreySimulator

Simulates foxes (predators) and rabbits (prey) in the wild. Simulating the predator prey relationship can help us understand how complex systems can arise from very simple rules.

Predator Prey Simulation

Fluid Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.fluid.ui.FluidSimulator

Deep water simulation based on work by Jos Stam. Use the mouse to stir up the fluid by clicking and dragging.

Fluid Simulation

Liquid Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.liquid.LiquidSimulator

Particle based fluid simulation based on Nick Fosters SIGGRAPH paper. Numerical instability (due to a bug) causes this simulation to blow up after a relatively short time unfortunately.

Liquid Simulation

2D Deep Water Simulation

bb4-simulator -panel_class com.barrybecker4.simulation.water.ui.WaterSimulator

Deep water simulation based on work by Kass and Miller. Drag the mouse to interactively change the height of the water or of the ocean floor.

2D Deep Water Simulation

Trebuchet

bb4-simulator -panel_class com.barrybecker4.simulation.trebuchet.TrebuchetSimulator

Simulate a trebuchet.This program uses a physically based model to represent a trebuchet. When my son and I were watching Lord of the Rings, we noticed that Minas Tirith used trebuchets to defend itself. We built one out of lego, but optimizing lego is tedious, so I made this virtual trebuchet in order to try different designs. The trebuchet can also "learn" to move more efficiently by a process of automated optimization. It uses exactly the optimization code I use for improving the performance of the game programs. This is still a work in progress. I need to use constrained dynamics for the projectile's attachement to the sling (instead of a simple spring based restorative force which leads to instability). When done, I hope to build a trebuchet with my son according to the optimized specifications.

Trebuchet

Spirograph

bb4-spirograph

Remember that psychodelic toy from the 70's? Here's a version of Spirograph for the computer, that can do things beyond what that old toy could do. Adapted from work done by David Little.

Spirograph

Sierpinski Triangle

bb4-sierpinski

This is an example of a self-similar set. \ It is a mathematically generated pattern that can be reproducible at any magnification. \ See Sierpinski Triangle

Sierpinski Triangle

L-System Tree

bb4-simulator -panel_class com.barrybecker4.simulation.lsystem.LSystemExplorer

Create trees from l-system expressions. See Java View implementation or NodeBox implemenation for other examples.

L-System Tree