N-body simulations of gravitational dynamics