World simulation for spacesim game.

Hello, could someone, please, suggest a good tutorial(or maybe personal experience) covering(partially or not) a creation of galaxy simmulation code for space sim game. Eventually, i’m interested in something that you could face in X-universe games (X - X3).

For instance, in X-games player could have a 100+ ai traders which are making their deals, findng a best prices and processing their own ai. In addition to that, there is a simulated galaxy with thousands of ships and living economy + ai can dp thing like fighting eachouther even if player cant see that.

I think there is some tricks to optimize this (direct approach is not that kind of thing, that CPU would appreciate for, i believe), so it would be nice to have some material about it.

Thanx for your time!

@Leight I have made a video regarding simulating gravity in outer space.
Take a look here : - Gravity Simulation