It's pretty brute-force right now -- I predict trajectories for everything (planet, moon, ships) a few hundred frames ahead with a gravity-only simulation. I also predict a hypothetical bullet if it were just fired from the player's ship, and then check along its path to find the closest ship it ever approaches in the future. Only celestial bodies attract, so that cuts down on computation.