 |
|  |
 |
|
samson
|
|
There have been several postings here over the years which describe formulae for caravan and freight delivery payments. Although most of the factors affecting the amount of payments have been identified, none of these formulae are able to predict the payment amount exactly in all cases. This is due to not recognizing that the order of application of the various bonuses and penalties is important and to the existance of a previously undescribed MapsizeFactor.
The following procedure can be used to accurately calculate caravan and freight delivery payments.
A base payment is first determined from the base trade of each city and the distance between them. The formula for this base payment is:
Base Payment = ((Distance x MapSizeFactor + 10) x (Total Base Trade) ) /24
This payment amount is then modified by a number of bonuses and penalties which must be applied in a specific order to derive the final delivery payment. The order of calculation and other information required is explained in the 10 steps that follow.
[Note about Civ2 math: All Civ2 algorithms which I have investigated use integer math. This means that any remainder left after a division operation is discarded. For example, the result of both 17/8 and 23/8 would be 2. There is no rounding. ]
Step 1) Calculate the Distance between the two cities. The distance between any two points on a Civ2 map can be determined from their X,Y coordinates, where X is a location on the East/West axis, and Y is on the North/South axis. The formula is:
Distance = (Xdistance + Ydistance)/2 + ( | Xdistance - Ydistance | )/4
If the coordinates of point A are (Xa, Ya) and the coordinates of point B are (Xb, Yb), then the absolute difference between Y coordinates is:
Ydistance = |Ya - Yb|.
Or, in other words, simply subtract the smaller Y value from the larger one.
On a FLAT map, the Xdistance value is found the same way:
Xdistance = |Xa - Xb|.
On a ROUND map, however, there will be two values which express the horizontal distance between two points: |Xa - Xb| and (C - |Xa - Xb|) where C is the circumference of the map. These values represent the X distances between the two points obtained by traveling East or West respectively. The Xdistance value used in calculating Civ2 distances is the smaller of these two numbers. Thus:
Xdistance = SmallerOf( |Xa - Xb| , (C - |Xa - Xb|) )
This calculation is easier to do in practice than it is to formally describe.
For example, given two points A(23, 71) and B( 84, 12) on a medium map (50 x 80),
where the circumference is 100:
Ydistance = 71 - 12 = 59.
Xdistance = SmallerOf( 84 - 23 , 100 - (84-23) = SmallerOf( 61, 39) = 39
Distance = (39 + 59)/2 + (|39 - 59|)/4 = 98/2 + 20/4 = 49 + 5 = 54
Step 2) Add the base trade of the two cities. The base trade of a city is determined in the City Display by subtracting any existing trade routes from the total number of trade arrows shown for the city. For a foreign city, the base trade can only be accurately known by investigating the city with a diplomat or spy. However, an estimate can be made from the city size, type of government, and knowledge of the terrain surrounding the city.
TotalBaseTrade = BaseTrade(City A) + BaseTrade(City B)
Step 3) Calculate the Base Payment from the formula:
Base Payment = ((Distance x MapSizeFactor + 10) x (Total Base Trade) ) /24
The MapSizeFactor for a medium map is 1, for a small map it is 5/4, and for a large map it is 4/5. Note that the effect of the MapSizeFactor is that for equal distances, the delivery payments on a small map will be 20% higher than on a medium map and 50% higher than on a large map.
Step 4) Apply the TwoContinentBonus. If the two cities are located on different continents (i.e. they have different continent numbers following their X,Y coordinates in the location field) then double the Base Payment derived in step 3.
Step 5) Apply the SameCivPenalty. If the two cities belong to the same civilization, then halve the value from Step 4. (Remember when doing this division by 2 to discard any remainder.)
Step 6) Apply the FreightBonus. If the delivery is by freight (as opposed to caravan) multiply the answer from Step 5 by 3/2. i.e., first multiply by 3 then divide by 2, discarding any remainder.
Step 7) Apply the DemandBonus. If the commodity being delivered is demanded by the destination city, then the amount from Step 6 is multiplied by a factor based on the type of commodity involved
Hides, Salt, Wool, Beads, Copper, Dye 2
Cloth, Coal, Wine, Silver 5/2
Silk, Spice, Gems, Gold 3
Oil 7/2
Uranium 4
Again, the bonuses expressed by fractions are applied by first multiplying by the upper number and then dividing by the lower.
Step 8) Calculate and apply the TransportationBonus. Unlike previous bonuses, the TransportationBonus consists of several factors which are first combined additively (expressed as a %) before being applied multiplicatively. These are the road, railroad, airport, and superhighways bonuses. Each has peculiarities which will be discussed.
The Road (50%) and Railroad (100%) bonuses are applied when a valid road or railroad connection exists between the Source and Destination cities. However, determining the specific route required to qualify for the bonus is problematic. First of all, except when the cities are directly aligned on either a North/South or East/West axis, it is likely that the Source-to-Destination route and the Destination-to-Source routes will be different.
Road and Rail bonuses are also used in determining the value of ongoing trade routes. For trade routes each city uses the Source-to-Destination route originating with itself. However, in determining the Road and Rail component of the TransportationBonus, it is the Destination-to-Source route that is used. This is somewhat obtuse and limits the value and frequency of this bonus.
The Airport bonus is applied when both cities have an Airport improvement. If the cities are on the same continent, the Airport bonus is 50%. If the cities are on different continents the bonus is 100%. There is no bonus if only one city has an airport.
The Superhighways bonus is 50% if only one city has the improvement and 100% if both cities have them. Additionally, of course, Superhighways will increase the BaseTrade of a city substantially, which in turn will increase the Base Payment calculated in Step 3. So Superhighways can appear to produce more than a 50% increase.
All applicable transport bonuses are added together to determine the TransportationBonus which is then applied to the result from Step 7.
Some examples:
a) Two cities on the same continent, one has superhighways: 50% bonus = multiplier of 3/2.
b) Two cities connected by railroad via the qualified route, one has superhighways: 150% bonus (rail + SH) = multiplier of 5/2.
c) Two cities on different continents, both have airports and superhighways: 200% bonus = multiplier of 3.
Step 9) Determine and apply the AgeModifier. The AgeModifier uses 4 key technologies to determine if your civilization is in the Ancient, Renaissance, Industrial, or Modern Age. Since it is possible, via trading with other civs, to acquire later techs without earlier ones, each of the following checks is made in sequence and the modifier applied appropriately.
Invention and Navigation are used to determine if your civ has progressed from Ancient to Renaissance. If you have acquired neither of these technologies and have not yet passed the 200 turns mark, the amount calculated from Steps 1-8 is doubled.
If your civ has acquired Railroad, your transition to the Industrial Age causes the payment amount to be reduced by one third. Unlike other modifiers, the 1/3 penalty is applied by dividing the Payment by 3 and then subtracting the result from the Payment. For example, one third of 17 is determined using integer math to be 5
and the applied penalty results in a payment of 12.
Flight signifies your civ's entry into the Modern Age and causes another 1/3 reduction penalty.
Step 10) Apply the ScienceCap. Delivery of a caravan/freight produces not only a cash payment but, in addition, an equal number of beakers are added to your current research. The Delivery Payment, as calculated in steps 1-9, cannot exceed 2/3 of the total beaker cost (determined at the moment of delivery) of your current research if that cost exceeds 300 beakers. Prior to the 300 beaker point, the ScienceCap is 200 plus a random amount between 0 and 10. At lower tech acquisition levels, it is possible for a single caravan delivery payment to provide more beakers than the total cost of current research. The state of progress of your current research has no effect on the ScienceCap which is based solely on the total cost of research. Whether you need 1 more beaker or the total amount, you will receive all the beakers of the Delivery Payment up to the ScienceCap.
Last edited by samson on 18-10-2002 at 01:21
|
|
|  |
 |
|
solo
|
|
Lowell, MA USA
Jan 2001 time: 05:23
|
|
samson,
There was another post earlier today asking about this. If this was done just this afternoon in response, I'm very impressed!
Seriously, one question I have is about Space Flight and whether or not it affects payouts. They really seem to tank after I discover Space Flight. Is this just my imagination, or has anyone else noticed this, too?
|
|
|  |
 |
|
Thoddy
|
|
Hannover, Germany
Jan 2001 time: 06:23
|
|
Step 8 Road and railroad bonus
the road(RR) connection must be at the optimal path.
(you can check the optimal path by using air units or units with flag threat all squares as road)
Bonus is lost if the distance between cities exceeds 22 squares (If the same calculating algorithm is used as the algorithm from the go to command.
Enemy units at the optimal path also avert these bonuses.
|
|
|  |
 |
|
samson
|
|
SG - I believe this describes the algorithm used in the latest patched versions of Civ2. I have used it to correctly predict the exact amount of hundreds of deliveries in test and game situations that employ all combinations of factors. If anyone has a counter-example, please post the save here ... I will investigate it.
Solo- I've had this sitting around for awhile. It just seemed to be an apt time to post it.
Thoddy-
The so called "optimal path" (Source-to-Destination) is used for determining whether to apply the ongoing Trade Route bonus. But for the Road/Railroad portion of the Delivery Bonus, it is the Destination-to-Source path which is used and this is usually not the same. While this is also an "optimal" path, it is chosen from the Destination City's POV, which is harder to determine when that city is foreign.
Yes, both the trade-route and delivery Road/Railroad bonus are lost if non-allied foreign units occupy the path. They don't even have to be "enemies" per se. Peaceful, but non-allied units disrupt the route also.
As for the 22 maximum squares, I have not seen this. In fact, I have a counterexample in my test suite. On a SMALL map, I have a city at a distance of 24 which does receive the Road/Rail bonus. I will investigate further to see if there is a maximum distance and whether it is dependent on other factors. Do you have example of this limit you could post as a save?
Sometimes an "optimal" path does not exist, if it is disrupted by a lake, for example.
There is another Road/Railroad bonus anomaly. Sometimes the road/railroad does not even need to be complete between the two cities. If a third city belonging to the same civ as the Source city is located along the "optimal" path and the road/railroad is complete between this city and the Destination city, the extension of the road from the intervening city to the Source city is not required. In other words, the Delivery Bonus algorithm seems to check for an "optimal" road/railroad from the Destination to Source but stops as soon as it encounters any city from the Source city's civ. This means a cheaper way of gaining the road/rail bonus for Delivery Payments is to build a city two squares from the Destination City on the optimal path and complete only that portion of the road/railroad. I can't claim that this always works but I know it works sometimes. And the distance to the Source city can be much greater than the distance to the intervening city. Note: this works for the Delivery Bonus and the Destination City's Trade Route bonus. It does not work for the Source City's Trade Route bonus.
Last edited by samson on 17-10-2002 at 20:46
|
|
|  |
 |
|
samson
|
|
Chofritz,
Yes, Salt when demanded receives 2x bonus, same as Hides, Beads. etc. Sorry about the omission, I'll edit the post.
As for your spread-sheet, a couple of things:
You've got the Airport bonus backwards. Different continents is 2, same continent should be 1.
Your Mapsizefactor cell treats an entry of 5/4 as a date. In any case, you shouldn't prompt for this value anyway. Just calculate the factor from the Circumference value entered into cell G1.
Also, it would be much more user-friendly, if you simply asked for the Commodity by name and whether it was demanded or not, then calculated the bonus.
Finally, the Gold Payment and the Science Payment are always the same. Sorry, if I didn't make that clear. If anyone has a counterexample to this claim, please post it.
|
|
|  |
 |
|
Chofritz
|
|
Stockholm, sweden
Aug 2001 time: 06:23
|
|
Ok, thanks for your replies. Here is an improved version. Tell me if there is anything I missed to fix or if there are any bugs.
Attachment: tradepayoff.txt
This has been downloaded 15 time(s).
|
|
|  |
 |
|
samson
|
|
Looks much better.
The only thing that is off a bit, is how you apply the 1/3 penalty for the discovery of Railroad and Flight. You are multiplying by 0.6667.
The algorithm used by the game calculates the 1/3 penalty by dividing the total-so-far by 3 (dropping the remainder) and then subtracting this penalty amount from the total-so-far. Your answer is sometimes off by 1 or 2 because of your approximation of the algorithm. You're so close, you might as well fix it and get the perfect answer.
Nice job, Chofritz.
|
|
|  |
 |
|
samson
|
|
Thoddy -
Okay, I see what you're talking about 22 squares. This isn't that same thing as a 'distance' of 22 the way the trade algorithm calculates distance.
If I place CityB 22 squares away from CityA in an exact NW direction connected by road, I get the road bonus. If I place it 23 squares away, I don't get the bonus. In this direction, 23 squares is a distance of 23.
However, if CityB is 16 squares away directly West, its distance is 24 and the road/railroad bonus is obtained.
So distance between points for calculation of trade is different than that used by the GOTO algorithm. Yet another bit of road/railroad funkiness.
|
|
|  |
 |
|
Elephant
|
|
Phila PA
Aug 2002 time: 00:23
|
|
quote: Originally posted by samson
Step 2) Add the base trade of the two cities. The base trade of a city is determined in the City Display by subtracting any existing trade routes from the total number of trade arrows shown for the city. For a foreign city, the base trade can only be accurately known by investigating the city with a diplomat or spy. However, an estimate can be made from the city size, type of government, and knowledge of the terrain surrounding the city.
|
So all city improvements and wonders count toward base trade, just not the trade routes?
I have found it very difficult to estimate foreign cities improvements, which could throw the total estimate way off. Just because they have the tech, they may not build it. Safest course is the dip/spy visit. Course, early in the game, can you afford to lose that many dips?
|
|
|  |
 |
|
samson
|
|
quote: So all city improvements and wonders count toward base trade, just not the trade routes? |
There is only one city improvement and one wonder that affect base trade: Superhighways and Colossus.
Colossus adds one trade arrow to each city square which is already producing at least one arrow, including the city center. This is the same effect that Republic and Democracy (and celebrating Monarchy, Commie, Fundy) governments have on a city.
Superhighways increases the trade of all squares which have roads or railroads by 50%. This is on a per square basis uses Civ2 integer math. Thus, a square with just one trade arrow is not improved by Superhighways, it must have at least two arrows to benefit. Also, remember that SH only effects squares with roads ... ocean squares or trade specials WITHOUT roads will not benefit. Despite these limitation, Superhighways is one of the most important city improvements in the game. In addition to increasing base trade, it also increases caravan delivery payments and the value of ongoing trade routes by 50%.
quote: I have found it very difficult to estimate foreign cities improvements. Just because they have the tech, they may not build it. Safest course is the dip/spy visit. Course, early in the game, can you afford to lose that many dips |
There's only two that affect trade bonuses: Superhighways and Airports, and neither of these appear early in the game. You only need to estimate the destination city's base trade.
|
|
|  |
 |
|
samson
|
|
quote: What I did next was to enter cheatmode giving myself 100 future techs to increase the research cost but it didn't move, is there a maximum research cost? |
Not that I know of, but using "Edit Technology" to give yourself 100 Future Techs doesn't work, it increments the # of the Future Tech but not the cost. You'll need to do SHIFT-F6 to give yourself one tech advance. Do this one hundred times, or however many techs you need to raise the cost higher than the payment.
I don't know if there is a maximum integer beyond which the Civ2 math breaks down. Probably not within the legimate context of the game.
|
|
|  |
 |
|
Thoddy
|
|
Hannover, Germany
Jan 2001 time: 06:23
|
|
Link to an attachment frome mine at another Apolyton Trade thread:
http://apolyton.net/forums/showthre...20&pagenumber=2
attachment: Preq: Fantastic worlds
(damn link doesnt work) look for cab_4000.sav
I saw some things depending from the "optimal Path" and the distance, but my focus was not the 1 time payment - I checked only the trade routes.
Last edited by Thoddy on 18-10-2002 at 12:58
|
|
|  |
 |
|
Elephant
|
|
Phila PA
Aug 2002 time: 00:23
|
|
quote: Originally posted by samson
There is only one city improvement and one wonder that affect base trade: Superhighways and Colossus...
There's only two (city improvements) that affect trade bonuses: Superhighways and Airports, and neither of these appear early in the game. You only need to estimate the destination city's base trade. |
My apologies, samson. Fuzzy thinking and rushing to make my bus home. I was confusing trade arrows with Gold/Lux/Beakers, which are significantly increased by city improvements and wonders.
Seems like the AI often roads and irrigates a few plains early in the game, but I cannot tell which square each citizen is actually working. In a game I was playing recently, the AI mined hills due east of the city and neglected mining the Wine/Hills to the north, which would have given them the extra base trade from the same citizen working the mines. AI seems to go for food first, then shields, then trade.
quote:
Superhighways increases the trade of all squares which have roads or railroads by 50%. This is on a per square basis uses Civ2 integer math. Thus, a square with just one trade arrow is not improved by Superhighways, it must have at least two arrows to benefit. Also, remember that SH only effects squares with roads ... ocean squares or trade specials WITHOUT roads will not benefit. |
So a road on Wine and Silk gets additional base trade in conjunction with SH, even though Hills and Forest do not normally get trade benefits from roading, right?
|
|
|  |
 |
|
Elephant
|
|
Phila PA
Aug 2002 time: 00:23
|
|
quote: Originally posted by samson
I don't know if there is a maximum integer beyond which the Civ2 math breaks down. Probably not within the legimate context of the game. |
Integer math tends to be two-byte functions, which gives you either 0->64K or -32K->+32K. Isn't the max amount of gold around 32K?
|
|
|  |
 |
|
solo
|
|
Lowell, MA USA
Jan 2001 time: 05:23
|
|
Elephant,
You are right about the gold maxing out around 32,000. The maximum number of cities is near another common integer storage limit of 128.
Civ II seems to do a good job of preventing the player from causing integer overflows, unlike some other games, such as SimCity 3000, where the variable keeping track of the quality of the buildings in your city is allowed to overflow. If you have too many buildings with the best rating ("astronomical"), the threshold is crossed, and your income drops to a level commensurate with having all your buildings rated at the lowest level! Not a lot of fun after spending so much time building a rich city!
|
|
|  |
 |
|
solo
|
|
Lowell, MA USA
Jan 2001 time: 05:23
|
|
I'm afraid I really meant 128! I was just wrong and apologize for my faulty memory. Is having been away from the game for over a year a good enough excuse?
|
|
|  |
 |
|
Elephant
|
|
Phila PA
Aug 2002 time: 00:23
|
|
256 is a single-byte number (2 raised to the 8th power). Makes sense.
Wonder what else has byte-integer limitations?
|
|
|  |
 |
|
Chofritz
|
|
Stockholm, sweden
Aug 2001 time: 06:23
|
|
BTW, get over there and play you (you as in all of you) too.
|
|
|  |
 |
|
Elephant
|
|
Phila PA
Aug 2002 time: 00:23
|
|
quote: Originally posted by Chofritz
BTW, get over there and play you (you as in all of you) too. |
I love to - I'm OCCing GOTM21 right now, but I'm also testing city demand changes and trying to keep a home life going too! What ever happened to MWHC (MyWifeHatesCiv)?
Interestingly, my daughter is getting into Civ2. She was doing some ancient history studies and I introduced her - now we talk about parallels between Civ and real history, tech development, struggles with Rep/Dem governments, military issues, etc. She's ony 10...
|
|
|  |
 |
|
Elephant
|
|
Phila PA
Aug 2002 time: 00:23
|
|
Samson: Railroading increases a square's Shield production by half again, rounded down, but does not SEEM to effect the "Base Trade". Yet they are mentioned together as having 50% bonus in either the manual or the help files (cant remember which). Please confirm my understanding that you are saying that the only benefit the Railroad has is to the Transportation Bonus, never to the Base Trade.
Last edited by Elephant on 22-10-2002 at 23:06
|
|
|  |
 |
|
samson
|
|
Elephant,
A railroad on the "optimal path" (ie, the "go to" route) from Source City to Destination City increases trade routes by 100%. A railroad on the Destination-to-Source path (usuallyt different from the Source-to-Destination) increases the delivery payment by 100%. Neither of these are considered part of the Base Trade of a city, which is the amount shown in the City Display, minus the trade routes.
Roads and Rails do not effect Base Trade except in conjunction with the Superhighways improvement.
|
|
|  |
All times are GMT. The time now is 05:23. Apolyton Time is 00:23. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|