During high school I wrote a C++ program that simulated thousands of masses and their gradual accretion via mutual gravity. Some simulations were designed to model the early universe: see this paper I wrote for Math 324 at the University of Washington.
Here’s another simulation designed to model the formation of the solar system: