Algorithm for generating spaceships