Short answer is “yes and no”. They may spawn closer but only by a virtue of both being pushed away from the civilization starts and because are allowed to be close to each other. Below is the homework done in arrival to that conclusion. Note, that I am not intimately familiar with the inner workings of map generation as I am not a developer or a modder, thus I may be unaware of any other possible factors at work here.
Order of map features placement
After scouring through Civilization 5 XML files and game scripts, here is what I had found as to how the game generates maps and places resources and starting locations.
The core function in the script
GenerateMap(). There one can see what steps the map generation goes through when determining locations of terrain, map features and assets (capitalization and grammar in this and following quotations is sic):
Assign Starting Plots, Place Natural Wonders, and Distribute Resources. Starting plots are wholly dependent on all the previous elements being in place. Natural Wonders are dependent on civ starts being in place, to keep them far enough away. Resources are dependent on start locations, Natural Wonders, as well as plots, terrain, rivers, lakes and features.
One of the final steps is to determine civilizations’ placements, place wonders and resources. It is handled via
Divide the map in to Regions, choose starting locations, place civs, place city states, Normalize locations, and place Resources.
From the steps that follow it is clear that natural wonders are placed before city-states. Placement logic is handled in
How the natural wonders are placed
There are several functions which the script goes through to determine if plot is eligible to be a natural wonder, and if so, what wonder it then would be (quoted are comments from the script itself):
- Check for collision with civ start location, rivers and lakes, snow and ice. “If a candidate plot passes all such checks, we will move on to checking it against specific needs for each particular NW.”
- Check for Geyser eligibility. “This site is inland, has hills or mountains, not too many tundra or desert, and not too many mountains, so it's good.”
- Check for Crater eligibility. “This site is inland, in desert or tundra with no grass around, and does not have too many hills and mountains, so it's good.”
- Check for the Rock of Gibraltar eligibility. Centre tile should be in the water or on the coast, surrounding tiles should have at least 3 coastal tiles, jungle and hills, but should not have desert, too many mountains or plains.
- Check for the Mount Fuji eligibility. Centre plot should be on proper land mass (not the biggest (unless there are no oceans), not on too small of an island), and surrounded by grassland and plains with no more than two hills nearby.
- Check for Mesa eligibility. “This site is inland with no grass around, and has a moderate amount of hills and mountains.”
- Check for the Great Barrier Reef eligibility. It needs to be surrounded by salt water with no ice, and at least 4 coastal tiles. “This is also the only natural wonder type with a footprint larger than seven tiles.”
- Check for Krakatoa the volcano eligibility. “Check the center plot, which must be ocean surrounded on all sides by more ocean.”
- Check for rare mystical wonder eligibility. Should be inland.
After that the candidate plot list is generated, and for each plot level of
OccurrenceFrequency parameter (from XML file) is recorded. Then another function attempts to place natural wonder at random location from the specific list for each wonder, checks for collisions with other wonders, and records its placement.
Why city states appear close to natural wonders
Civilization 5 uses so-called “impact and ripple” system to determine the minimum distances between certain type of objects. There are several Impact Data Layers (strategic, natural wonder, city state, luxury resource and so forth), for each of which the ripple value of each feature is recorded. Civilization starts are created with ripple value of 4 towards natural wonders level (“set a minimum distance of 5 plots (4 ripples) away”). But the city states are also pushed away from starting locations. The reference at the bottom of AssignStartingPlots script (very handy resource, along with in-line documentation) states:
The city state locations are chosen. Two methods exist: regional placement, which strongly favors the edges of regions (civ starts strongly favor the center of regions), and Uninhabited, which are completely random.
At the same time, natural wonders are created with ripple value of 1 towards city state level which allows for close proximity. Hence, insofar it seems that perceived tie between city state and natural wonder placement is coincidental.