Modeling balls bouncing in a box