The key to understanding Supply and Demand lists in cities is recognizing that each commodity has its own formula and set of determining factors which govern its appearance and disappearance. Each of these commodity formulae derive what I call a Supply Quotient and a Demand Quotient. When a trigger event occurs, such as the 16-turn "solo" cycle, the SQ and DQ are calculated for each of the sixteen commodities.
If a particular commodity's Demand Quotient is higher than its Supply Quotient, it goes on a roster of demanded commodities. If not, it goes on the supplied commodities roster. (This prevents a commodity from being both supplied and demanded by the same city, as a rule.) The top three commodities on each roster become the city's supply and demand list.
If either the supply or demand roster does not have enough commodities to fill its list, then the commodity with the highest ID number that is enabled and not already on the list is used.
There are also two Wildcard commodities, one for supply and one for demand. These are based solely on the city's map coordinates. The wildcard formulae are:
Supply Wildcard = RemainderOf ( (Horizontal x 13 + Vertical x 7) / 14)
Demand Wildcard = RemainderOf ( ( Horizontal x 3 + Vertical x 5) / 14)
Because coordinate pairs on Civ2 maps are always either both even or both odd, the remainder from this division by 14 is an even number between 0 and 12. This number is used as an index into the commodity list to choose the Wildcard. The commodity list is:
Each Wildcard is then checked against the six commodities on the Supply and Demand lists and against the other wildcard to prevent duplicates. If the Wildcard is not present on either list, it replaces the middle commodity on its respective list.
After a civilization has acquired 32 Techs, the wildcard formulae for its cities changes slightly. The divisor is now 9 instead of 14, and 5 is added to the remainder, as follows:
Supply Wildcard = RemainderOf ( (Horizontal x 13 + Vertical x 7) / 9) + 5
Demand Wildcard = RemainderOf ( ( Horizontal x 3 + Vertical x 5) / 9) + 5
This eliminates commodities 0-4 (Hides to Salt) from the Wildcard spot in the middle and late game and allows odd numbered commodities to appear. Again, if the wildcard commodity is already present on either list, it is not used and the originally determined 3 commodities remain.
If the supply and demand Wildcards are the same commodity, it is used only on the demand list.
After the discovery of Industrialization, Oil becomes available as a secondary wildcard, used to substitute the middle commodity when the primary wildcard was eliminated as a duplicate. It is because of its role as a secondary wildcard that Oil sometimes appears on both the Supply and Demand lists of a city.
Wildcard commodities, when present, always appear in the middle position on the list.
Determinants of Supply and Demand
The formulae for calculating each commodity's Supply and Demand Quotients involve a number of factors.
Terrain. Terrain is probably the most important factor in determining supply and demand. The terrain of all 21 squares in the city radius are counted by type to create a city's Terrain Profile. Resource specials count as 4 of their base type. Thus, Fish and Whale count as 4 Ocean; Wine counts as 4 Hills; Wheat counts as 4 Plains, etc. Rivers are counted as a separate terrain type, making for a total of 11 terrain counts. Each commodity's selection and weighting of terrain types will be unique.
Location. In addition to the Wildcard calculation, location affects a number of commodity SQs and DQs. Location's role includes use of the city map coordinates in calculating proximity to the poles or equator for a simulation of historical distribution patterns of commodities.
Continent. Continent number and continent size(?) are important determinants for some commodities.
City Size. The population of a city affects many commodity SQs and DQs, but in different ways. There is no one city size algorithm, although a pattern of 3, 8, 13, etc. (increments of 5) occurs in a number of instances.
Tech Acquisition. The number of techs acquired is used as a measure of progress and time passage, reducing or increasing demand and supply of certain commodities in simulation of their historical importance to civilization. Specific technological advances have profound affects on certain commodities, many of these are well known, such as Industrialization and Automobile's impact on Oil. Tech acquisition applies to all cities in a civilization. In a few rare cases, a tech discovery may have global impact.
City Improvements. Some city improvements affect the SQs and DQs of commodities for that specific city.
Nationality. Occasionally, a civ's historical association with a specific commodity is reflected in its supply and demand. French cities are more likely to be suppliers of Wine, while Silk is often common in Chinese cities.
Some of these determining factors are static, unchanging throughout the game, or change only rarely (like terrain). Others change rapidly over time. It is the changing factors alone, City Size and Tech Acquistion, that are responsible for the changes in supply and demand lists that occur over the course of the game. Once all of the commodity SQ and DQ formulae are known and well-tested, it will be possible to determine not only the initial commodities of a newly founded city, but to chart all future changes to these lists based on city growth, terrain modification, and the strategic acquistion of technologies.