Civ4Calc: Precise calculations for anal-retentive perfectionists

Blkbird

King
Joined
Oct 29, 2005
Messages
860
After spending way to much time manually calculating whether the production overflow of one build will be enough to speed up the next build by one turn, I've finally decided to write a calculator for it. Of course, there are other calculations I'm spending too much time on as well, so I'm planning to expand the functionality of this calculator in time to come. Suggestions welcome!

Edit: A second function calculating unit healing has been added, see #10 below.

Download: in the download database

This is a Python 3 script (incompatible with Python 2.x, but both Python versions can be installed side-by-side without problems) with interactive command line. The syntax of the production calculation is:

Code:
p [built/]build: [over>][base][@rate][+plus][*turns], ...

Full documentation of the syntax is available via "help p".

Starting with a trivial example, a Library (90) in a city with 20 base production, no overflow from previous build and no production boost whatsoever:

Code:
> p 90: 20
Finishing in 5 turn(s) with an overflow of 10.

And if the city has a Forge (+25%) and 5 production overflow from previous build:

Code:
> p 90: 5>20@125
Finishing in 4 turn(s) with an overflow of 12.

Note it's "5>20" because that is the order these numbers are shown in the city screen.

Now for something few people can calculate quickly in their heads, what if the city is expecting the spread of the State Religion, which gives +25% under Organized Religion, and 10 extra production from forest chopping, both in 2 turns?

Code:
> p 90: 5>20@125*2, 10>@150
Finishing in 3 turn(s) with an overflow of 7.

And if the chopping finishes 1 turn earlier (which is bad because it misses the state religion boost), while the base production increases to 21 at the same time as State Religion arrives:

Code:
> p 90: 5>20@125*1, 10>*1, 21@150
Finishing in 3 turn(s) with an overflow of 6.

There is also a verbose version, "prod" instead of "p":

Code:
> prod 90: 5>20@125*1, 10>*1, 21@150
In 1 turn(s): 31/90...
In 2 turn(s): 68/90...
In 3 turn(s): 99/90...
Finishing in 3 turn(s) with an overflow of 6.

I hope a few people here will find this calculator useful, for I believe there are quite a number of anal-retentive perfectionists among us Civ fanatics. :lol:
 
Note that Civ4's production overflow calculation is buggy, as I've recently reported. Of course, this script calculates in the same buggy way, otherwise it would be useless.
 
Two new parameters have been added: "done" for the part of the build that is already done at the starting point of the calculation, and "plus" for the additional production through food surplus when training settler or worker. The surplus is special because it's unaffected by any modifiers of the production rate, unlike the base production and the overflow.

And because the "plus" parameter needs the "+" sign, the "over" parameter now uses ">".
 
The syntax "build[-done]" has been changed to "[done/]build" so as to be consistent with the game's city screen, as well as the upcoming new function to calculate healing.
 
I think BUG does a lot of these calculations for you, but in-game. If not, I think your code would fit right in.

I've never used it (yet), but I thought its function is to show existing information more conveniently, not to calculate the effects of hypothetical decisions for the future.

If I want to know what would happen to my build if I change my civic in two turns, that's not information regarding to the current play. If this calculation were to be built in-game, it would need extra interfaces to input that hypothetical case (or more precisely, the manually calculated change to production in that case, because for such cases to be assessed automatically, the game engine would need to do incredibly, almost impossibly complex global calculations, for obviously everything is related to everything in Civ).
 
Ah, whipping. Well, I'm anti-slavery player and have never whipped anything in any of my games. So, I'm quite unfamiliar with that subject.
 
As indicated before, a second function calculating unit healing has now been added to the calculator:

Code:
h strength/full: [inst>][proms][[+help]...][@[terr][city]][*turns], ...

Again, full documentation is available via "help h".

Now this looks more complicated than production calculation, and it is. Among others, it's because things like terrain and promotions are hard to specify as numbers. Of course they do have quantifiable values in regard to healing, but why should anyone have to remember them if they're using this calculator?

Starting simple, an Axeman with a current strength of 0.1/5 healing up in a city with Hospital ("h") that belongs to a civ with which we're at peace ("r" for "rival"):

Code:
> h 0.1/5: @rh
Healing up in 4 turn(s).

To make thing complicated, let's say the Axeman has Combat IV ("c4") and March (so he can heal while moving), is to be promoted with Morale (or any other non-medical promotion) for some instant healing, then moving through enemy terrain ("et") for 1 turn, stopping at a Fort in neutral territory ("nf") for 1 turn where an ally unit with Medic I and II ("m1m2") and another with Woodsman III ("w3") are fortified, finally ending up at the rival city with Hospital ("rh"):

Code:
> h 0.1/5: 1>c4@et*1, +m1m2+w3@nf*1, @rh
Healing up in 3 turn(s).

A step-by-step replay:

Code:
> heal 0.1/5: 1>c4@et*1, +m1m2+w3@nf*1, @rh
Through instant healing: 2.5/5...
In 1 turn(s): 2.7/5...
In 2 turn(s): 4.9/5...
In 3 turn(s): 7.6/5...
Healing up in 3 turn(s).

As we can see, he's nearly healed up (4.9/5) at the end of the second turn, so going to a rival city with hospital isn't really necessary. Knowing this, we may decide to give him a different order...
 
Back
Top Bottom