Not a code diver, but I'm pretty confident in the conventional wisdom here..... barb cities require a barb unit to be present and don't follow the normal spawn/fog busting rules that barb units do. Meaning a city can spawn in a tile that's 2 tiles away from a unit if it's not visible, and if a barb is present. That syncs up with my anecdotal experience, of sometimes a barb city spawning even in an area that's spawn busted, and also from crying out at "bad luck" that a barb city spawned the turn i moved my unit away. In reality I'm overstating how unlucky I am, since I probably moved my unit away because it was chased by a strong barb, and then that matches conditions for barb city creation for possibly the first time. It also matches with my experience like Fippy said, that in isolation games, where I often have much of the island unsettled for 100+ turns, there's no breaches with barb cities once I've spawn busted all possible barb units, even though I'm certainly not maintaining vision on all tiles. It even syncs up with the hellish Charlie game. The reason it's so very likely that a barb city spawns above your capital, is because a barb unit will spawn there very quickly. It's connected by land to the continent with an impassable mountain, so that unit can't ever leave. Since that unit is stuck there, a barb city is inevitable in fairly short order.