They use a heirachy, much how us humans use them. The queen ant identifies its children, and they are 'recognised' by the other ants as the queen when the current queen ant dies. If there isn't an heir, a new queen is selected. I'm not sure how they come to this decision.