We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch
At first, I will quickly answer Bol's question:
If you want to center on the 3rd marine that is found in a location you have to give or move 2 marines away first. Then center on the marine, and give/move the other 2 marines back. There's not really another way.
Now on to how the game determines what is the 1st, 2nd, etc. unit in a location. What MillenniumArmy said, is not entirely correct.
First sc checks the x coordinate of the units in question. Lower x-values (leftmost) will be chosen first. (So far MA was correct)
But if 2 or more units have the same x coordinate sc checks their UnitID, higher IDs first.
Think about it: Checking the y coordinate could fail for flying or burrowed units.
You may ask now how is the UnitID assigned? There's several rules for for different cases for it:
1) Preplaced units:
- If you're using Staredit, or X-tra Editor the UnitID is based on the y coordinate. Lower y coordinate => Lower UnitID. That is the reason why those editors cannot create perfect stacks of units (like the 50 mineral patches of fastest maps). And that is probably where MA's misinformation is coming from.
- If you're using ScmDraft 2 or Starforge however, UnitID is based upon order of placement. Units placed first have lower UnitIDs.
2) Units created in game:
Units that are created in game apply to the same rule as ScmDraft 2 and Starforge: Units created first have lower UnitIDs.
Now keep in mind the creation pattern of units. They're like spiraling counterclockwise around the center. That means units are created like this (ideally):
qponm
redcl
sfabk
tghij
uvwxyNow look at the leftmost column: qrstu
The units are created from top to bottom => bottommost units get detected first. That is another reason why the incorrect y-coordinate rule is so widely spread.
And incase you want to know what happens if you create 25 marines with 1 action, honestly I don't know. But I think they're also spiralled around the center, but within a single trigger loop.