1.4.4: Most Accurate Ever

After finally working out the entire income formula, I’ve improved CNExtend to the point where may be one of the most accurate calculators available for CN.

That’s a bold statement, but the truth is for certain improvements it’s enormously difficult to get within ~.5% accuracy. Let me give an example:

Let’s say we have a nation with 1000 working citizens, a gross income of 100, and a tax rate of 30%. They buy a clinic. What is the change in their collection, normalized for a single day?

Figured it out yet? Of course not, it was a trick question. You still don’t have enough information. For starters, you need to know how many other clinics they already have. Since improvements of the same type stack, adding one clinic when you have 4 existing clinics will yield a different result than if you had zero existing clinics.

So, let’s say we have a nation with 1000 working citizens, a gross income of 100, a tax rate of 30%, and two existing clinics. I’m sure you can guess given the size of this post that is still not enough information. We also need to know how many soldiers they have!

What do soldiers have to do with population? It turns out that after all modifiers such as clinics are added, soldiers subtract an absolute number of citizens. Specifically, the number of soldiers * 0.01 * (environment – 1). Since this happens after clinics have their effect, we need to re-add that population before we can start figuring out what impact this new clinic had. Since this impact involves environment we need to know their environment rating as well.

So, amongst our nations properties are such diverse elements as: 1000 working citizens, a gross income of 100, a tax rate of 30%, two existing clinics, an environment of 3, and 500 soldiers. Is that enough? Well, as it turns out that will get you pretty close. But it’s still not enough.

When you add population, you end up decreasing your income. It’s not generally a large amount for most nations, and the effect is hardly noticeable when buying infra because infra mitigates this effect. However, increasing population through land, wonders, or improvements will have a small but noticeable effect on your income. Since this effect includes infrastructure we need to know that. Oh, and we also need to know about any income modifiers at all since they all apply to this effect. Banks, Guerrilla Camps, etc.

(For those pointing out that you can’t have all these improvements with so few citizens, or that the infra vs citizens ratio isn’t right, I know, it’s just a simplified example)
1000 working citizens, a gross income of 100, a tax rate of 30%, two existing clinics, an environment of 3, 200 soldiers, 400 infra, 3 Banks, and a Harbor. Any of these things change and you get a different result. And this is just a clinic.

A border wall includes a population change, a happiness change, and an environment change. Environment changes on their own also cause happiness changes and population changes. Both the original and indirect happiness changes cause income changes, and so do both of the population changes. They are by far the worst, and getting them to within 1% accuracy has been quite a challenge. At this point population improvements are within .1% accuracy, and I believe that any further improvements will have to come from figuring out exactly where rounding is occurring. At some point it will be impossible due to the fact that the infrastructure numbers stored internally are more accurate than the ones displayed. For instance, you can buy .001 infra or .005 infra and it can have an impact on your population.

Fortunately, I don’t need an individual formula for each improvement. Instead, CNExtend extrapolates changes to your stats based on the improvement’s properties, which are generalized for things like population, environment, and how many if any existing improvements of that type you have.

Well, this update is long enough as it is. By the way, if you figure out the answer to the clinic problem, post it up in the comments. First person to get it right while showing their work gets 3mil, 50 tech, and a gold star.

12 Responses to “1.4.4: Most Accurate Ever”

  1. Energizer Says:

    Clinic answer

    1000 working citizens, a gross income of 100, a tax rate of 30%, two existing clinics, an environment of 3, 200 soldiers, 400 infra, 3 Banks, and a Harbor.

    1000 citizens * 1.04 from clinics = 1040 working citizens
    1040 citizens – 6 from soldiers/enviroment (200 * 0.01 * (envioment(4) – 1)) = 1034 citizens
    1034 citizens make an avg gross of 100
    100 * 21% = 121 avg gross income
    121 * 1% from harbor = 122.21 avg gross income
    122.21 * 30% tax rate = 36.663/citizen
    Collection = 37,909.54

    Now, you add in the clinic to be purchased :
    1054 citizens make an avg gross income of 122.21
    collection = 38,642.80

    Also, any word on the tech market you plan to bring out for CNxtend? Looking forward to it :D

  2. babelphish Says:

    This is a good attempt, although not quite right. To clarify, pretend that the numbers listed are the numbers actually shown on your nation screen before you buy the clinic. Thus, an environment of 3 just means that 3 is listed by environment, and 1000 working citizens is listed as your total working citizens.

    Two hints: You want to add the soldiers first, and since the 1000 citizens is after the two clinic modifications, you actually need to divide by 1.04 and multiply by 1.06 to get the new clinic effect.

    Here’s an outline of the equation needed to reverse engineer it:

    ((unknown base population) * two clinics) – (soldiers) = (known final population: 1000)

    First figure out the unknown base population, and then figure out the new final population with the third clinic.

    Oh, and as far as the tech stuff goes, it’s coming slowly. I tend to go on tangents (testing, automation, whatever), but ultimately I expect that the result will be of a higher quality.

  3. Energizer Says:

    Oh whoops, heh. I assumed 1000 was the base pop, my mistake :P

    Neways…
    X * 1.04 – 200 = 1000
    X * 1.04/1.04 = 1200/1.04
    X = 1154

    1154 x 1.06 = 1223

    1223 citizens making 36.663/citizen = 44,838.84 daily income

    Of course then there’s environment which is another 4 (200 * 0.01(3-1) citizens gone.. where? O.O *twilight zone music plays*

    assuming that the 4 citizens is part of the known final 1k pop, then we have this for our REAL final answer;

    X * 1.04 – 204 = 1000
    X = 1158

    1158 * 1.06 = 1227 citizens which make a daily profit of 44,985.50

    But I think the bigger question is how can 400 infra produce anything less then 2800 citizens o.o

  4. Optical Says:

    The answer is 3!

    amirite?

    BTW, CNextend is an awesome addon, keep up the good work.

  5. Riccars Says:

    good stuff, just wondering when it shows the pop-up for potential profit for improvements does it compensate for daily upkeep of an additional improvement?

  6. Ghux Says:

    42
    problem solved.

    can i get my 50 tech now?

    PS this addon rocks

  7. MindstormsKid Says:

    Riccars: Nope.

    Ghux: Go away :P

  8. Emares Says:

    There is a way to discover completely accurate numbers for every nations infra land and tech from a single screen.

    Each nation has a charts screen on which is shown the NS contributed by each of the above. But hidden in the source code of that page is the fully accurate 12 decimal place long strength numbers. Once you have those then using the NS formula you can divide each one by their multiplier to get the fully accurate infra/tech/land numbers for the nation whose chart you are viewing.

  9. Sb Says:

    Hi, I love your addon. I have a question though. I want to buy my first Wonder in CN:S. I was surprised by some of the numbers while highlighting over some of them. I paid bills before this and have 7 days without collecting. Refreshed front page again to make sure your addon can compute after I did this.

    One thing I don’t understand is for the Great Temple, here is what shows up while I highlight over it and my notes pasted:

    08-07 CNExtend: Daily Collection Change + $195,081 a day.
    Defcon 5 and Low Threat.

    08-07 CNExtend: Change if People are Unhappy with Religion + $243,851 Defcon 5 and Low Threat.
    Don’t see how this can be even more if you pick one they do not want.

    I guess I don’t understand the Unhappy part of it, you get more money daily if you pick ones they do NOT want? Or should it say this is what you get when you both choose the same one?

    On the Stock Market. I guess that $10 more which would be for me $2.80 (28% tax) more per person turns out to be more. So if you go over a certain number before collecting and/or after maybe you get +1 happiness and/or better environment. Or I suppose it could be right on the edge and hard to say either way. Running the numbers it’s $44,380 more than what I thought it would be a day.

    Just was curious especially about the “If Citizens are Unhappy” you get more money. This must of been pretty hard to do and kind of fun if you already had a grasp of doing the numbers thing, which I don’t anymore.

    Would it be too hard to have it recognize between CN:S and CN:TE so can have different notes show up for both in the Custom Header? I’m sure it’s probably the way CN has their website setup. I notice with CookieSafe just cybernations.net shows up for both of them and tournament isn’t in front for that cookie.

    Thanks for your time.

  10. David Says:

    Hi there! I’m curious if you’re going to create a version of CN Extend for Firefox V3. (I’m on Firefox 3.5.2 right now, and it tells me, when I try to install, that it’s not compatible.

  11. Janquel Says:

    Hey Sb – I’m not the person who writes this, but I can hopefully resolve your questions.

    The output for Great Temple is likely saying what the increase for the wonder would be if your people were not currently happy with their religion. In other words, if your people were not currently happy with their religion, the benefit of the Great Temple is higher.

    I’m not entirely certain what you’re asking in the latter portion – it looks like maybe you’re forgetting to include income modifiers? Using only improvements, every $2 in-game translates to roughly $4.15 in income increases. So this means that the $10 from the Stock Market would be roughly $20.75, or $5.81 per person after taxes. Might this be where the discrepancy arises?

  12. Chiles Says:

    The extension won’t install because it isn’t compatible with FF 3.5.2. Is this fixable or will there be an update?