Separate the main simulation as a separate function.