1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Research cost formula v1.29f

Discussion in 'Civ3 - Strategy & Tips' started by mydisease, Aug 11, 2002.

  1. Charis

    Charis Realms Beyond

    Joined:
    Dec 20, 2001
    Messages:
    1,837
    Location:
    Midwest, USA
    Thanks for pointing out some other examples, as I don't
    have any sets on hand for examples and 'correct' answers.

    The two formulae are getting closer -- if I pull my 'cost'
    over inside the truncation, the results get much closer to yours, but still not identical. If I make the 1.75*CL term a division instead of a multiplication, I think we're identical:

    Modified version:
    Research cost = MF/CF * [ 10*COST - 10*COST*N/[7*CL/4] ] / 10

    That's now quite similar to yours

    Well... due to differences in rounding, the *ONLY* answer that "always gives the correct result" is the one used by the program :p

    The thing is, it's 99.9% certain they're just using integer math, nothing but truncation, no roundup function for sure. If you ever get something that 'looks like' a roundup it's always coded as something MINUS what you have. For example, 10 - roundup(n) is the same as [10 - n]. So it's closer to the code, easier to view as integers, and cleaner to express the terms with [ ] instead of function calls. In this specific case, I think that the trunc formula I give above is identical to yours, using the roundup to rounddown conversion. You have COST - UP(Cost*X) where I've written Down(Cost-Cost*X)

    The two things I'm left wondering -
    i) an alternate formula I looked at in the middle gives *very* close results --
    Research cost ?= MF/CF* [ 10*COST - 10*COST*N*4*CL/7] / 10
    It gives 14008 instead of 14000 beakers, for you example. Or 27 beakers for the other example. Are you sure it's 14000, not 14008?
    ii) Is the correct 'scaling' term used 10? ie, Up_0.1 or Up_somethingElse?

    In practical terms,
    Research cost = MF/CF * [ 10*COST - 10*COST*N/[7*CL/4] ] / 10
    (written like this or as you have it) is extremely close if not exactly what the program uses.

    Again, nice job,
    Charis

    (Edit - fixed N typo as pointed out next post)
     
  2. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    You're an odd fellow Charis. You can intuitively make complex transformations of multiple variable formulae and yet you also fail to realise that 1.75 is exactly equal to 7/4 and is a simpler way of writing it. And you miss out the N term(number of civs) 3 times despite the fact that it is THE critical term in the formula. Anyway, the formula that you worked out (if you put the N term in;)) is right. But far from being a different formula, it is in fact the same one as is written at the top of the thread. Sit back and witness the power of mathematics.....

    [MM/CF * (COST - UP.1(COST*N/[CL*1.75]))]

    = [MM/CF * (COST - UP(10*COST*N/[CL*1.75])/10)]

    = [MM/CF * (10*COST - UP(10*COST*N/[CL*1.75]))/10]

    And using a - UP(b) = [a - b]:

    = [MM/CF * [10*COST - 10*COST*N/[CL*1.75]]/10]

    Take out a common factor of 10*COST:

    = [MM/CF * [10*COST * (1 - N/[CL*1.75])]/10]

    = [MM * [10*COST * (1 - N/[CL*1.75])]/(CF * 10)]

    And if you insist:

    = [MM * [10*COST * (1 - N/[CL*7/4])]/(CF * 10)]

    So Research Cost = - Research Done So Far

    And remebering the two formulae are exactly the same, the only choice between them can be which one is simplest. The one in the civ3 code will be the last one and this may be quicker for a computer to execute, but myself, I find the first one easier to use. Ah well, maybe I should make a poll on the question.

    And to answer your questions,i) No, the truncation of (CL*1.75) really is necessary as I checked on hundreds of results when working out the formula originally. No, I don't have those results anymore as they were all on paper and they were cluttering up my desk, so I got rid of them. Hence, I'm not 100% sure it's 14000 and not 14008, but I bet you a pint that it will be.
    ii) Yep, the correct scaling is ten. If it wasn't exactly ten, for higher values of N the formula would give wrong results and I've checked for values of N in the range 2 to 15 and found no wrong results.
     
  3. Charis

    Charis Realms Beyond

    Joined:
    Dec 20, 2001
    Messages:
    1,837
    Location:
    Midwest, USA
    That's what I said! :)
    "I think that the trunc formula I give above is identical to yours"

    I like your latest incarnation 'img' formula best, with 1.75 and all round-downs, for what that's worth :p The "top of thread" one was full of arrows going in different directions and mysterious ".1"

    When I originally replied, I *knew* the given formula was not the one used by the computer and so had to be wrong, unless.... it was a direct transformation of the one used (which didn't look like it was going to happen)

    As it turns out, it was. Which means unless data shows otherwise, you've nailed it exactly, not just as a good approximation. :goodjob:

    As for which is easier to read... a poll might be overboard but it sure wasn't clear to GreyFox for a few iterations

    Followup - is there a simple relationship between cost to *BUY* in trade (or sell) and research cost left? It's basically a discount factor that's difficulty dependent, and a big markup on a monopoly tech, but there also seem to be few techs including govt techs plus Nationalism that go for premiums.

    Charis

    (PS I sure hope you didn't think 1.75 = 7/4 was lost on me!
    Oh and thanks for pointing out not typing in the N term)
     
  4. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    As far as I can tell from limited investigations, there is a very complex relationship between trade values of tech and research cost. For an interesting discussion of the variables that might be involved, see this thread:

    http://forums.civfanatics.com/showthread.php?s=&threadid=33670

    And I was only joking about the 7/4=1.75 thing:p . I just think 1.75 is simpler than 7/4 and this is what the programmers would use. Not that it matters at all, really.
     
  5. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    Once upon a time, a formula was conceived that was so complex that all who encountered it were reduced to confusion at it's hideous collection of archaic roundings of monstrous variety. However, a bold mathematician named Charis was committed to free the world from the evil clutches of mydisease and his hideous formula. The formula was banished forever from the land of Discusiones Generales in the world of Civfanatica. All that remains is a faint memory, buried deep in the unread archives of this glorious realm. And the archives read:

    This is the formula for research cost for v1.29f. I have attached an image of the formula as it is easier to visualize that way than in plain text. Also it is now simplified for your pleasure ;).

    Research Cost = - Research done so far

    I'll also write it out for those who cannot view images.

    Research Cost = DOWN{MM/CF * [COST - UP.1(COST*N/DOWN(CL*1.75))]} - Research done so far

    Research Cost and research done so far are in gold.

    Down Arrow or DOWN() means round down the figure inside the brackets to the next integer.
    Up Arrow.1 or UP.1() means round up the figure inside the brackets to the next decimal of .1 ending(can some mathematician tell me how to say that better?)

    MM = map modifier(tech rate on world sizes tab in the editor)
    Tiny 160
    Small 200
    Standard 240
    Large 320
    Huge 400

    CF = AI cost factor(as on the difficulty tab in the editor)
    For the purposes of the research cost formula, CF has a maximum value of 10.
    Chieftain 10
    Warlord 10
    Regent 10
    Monarch 9
    Emperor 8
    Deity 6

    COST = technology cost as on the civilization advances tab in the editor.

    N = number of civs on the diplomacy screen that have discovered the tech.

    CL = number of civs left in the game

    There is only one part of the formula that varies during the game and this is the last part : COST*N/DOWN(CL*1.75). There are two ways in which you can increase it to lower tech cost:
    1. Increase N by exploring and buying comms to add civs to your diplomacy screen.
    2. Decrease CL by killing civs.

    NB. This formula is relevant for research cost of the AI civs, not just the human player. If you are interested in the research cost of a specific technology for a specific AI civ, N refers to the number of civs on that specific AI civ's diplomacy screen that have discovered that specific tech. In general, there are two ways in which you can increase AI tech cost:
    3. Keep N low by not selling comms to AI civs.
    4. Keep CL high by not killing civs.
    And technically...
    5. Keep N low by not getting techs yourself.

    Obviously points 2. and 4. are contradictory so choose whichever fits your playing style. Personally I choose point 2.
    :ar15::king::queen::king::queen::king::queen:

    WARNING : ANY ATTEMPT TO USE THE ABOVE FORMULA WILL RESULT IN THE SPONTANEOUS COMBUSTION OF THE PARTY INVOLVED
     
  6. Gramphos

    Gramphos Emperor

    Joined:
    Sep 1, 2001
    Messages:
    1,139
    Location:
    Sweden
    Nice thread... too bad I didn't find it before figuring out the forumla (used in C3MT) myself.
     
  7. Gramphos

    Gramphos Emperor

    Joined:
    Sep 1, 2001
    Messages:
    1,139
    Location:
    Sweden
    MaxCost = [(10 * COST * MM) / (CF * 10)]
    MC=MaxCost

    That part is the same as in your formula (If you remove the modifier (1 - N/[CL*1.75]))


    So the only difference in my formula verses yours is my truncation of big results.

    To get the modified cost I then use
    Research Cost=[MC * [10 ^4 * (1 - N / (2 * CL - [(CL + 3) / 4])]) / 10^4]

    The 10^4 has to do with the way the game rounds down the reduced cost when it is that big, so appart from that your (1 - N/[CL*1.75]) should be the same as my (1 - N / (2 * CL - [(CL + 3) / 4])])...

    After some checks I'm sure that they are idenctical for integer values of CL
     
  8. alexman

    alexman King

    Joined:
    Feb 28, 2002
    Messages:
    778
    Location:
    Maryland, USA
    How certain are you of the term (1-N/[CL*1.75])?

    I always thought this term was (1-N/[2*(CL-1)]), which evaluates to 0.5 when everyone except you knows a tech, and I seem to recall someone from Firaxis mentioning that this was the case.

    In any case, the difference is small, and the two are the same for CL=8 (standard size, max civs).

    Edit: I guess if you are the only civ left on the planet and keep on playing, (CL-1) would result in a division by zero, so that's why they may have chosen the 1.75 factor instead.
     
  9. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    Sorry about the lateness of my reply, I've been away from the site and Civ 3 for about six months; came back mainly just to get some stuff from Creation and Customization. Anyway, in reply:

    Alexman: It rarely evaluates to 0.5 when everyone except you knows the tech in the game. Play a tiny 2 civ map to see; it should be 0.66. 16 civ maps can go as low as about 0.33 as I remember. The 1.75 originates from a former version of the formula in a previous patch where it was 1.5 and they changed it to decrease tech devaluation.

    Gramphos: You do realise that [(10 * COST * MM) / (CF * 10)] = [COST*MM/CF], ie. the 10 cancels. Mine and your formula are pretty similar and I don't have the data to check against anymore. All I can say is that I checked every value of civs left for maps with 2-16 civs. That's about 500 values and all of them agreed with the formula I derived. While working out the formula, I worked through various formulae which would be right on 90% of these values and it would be hard to disprove them and I think your formula is probably like one of these. If you check over a range of civs left on maps with a number of civs that is not a multiple of 4(ideally 13,14 or 15 civs), then you'll probably come across values where your formula doesn't agree with the values in game. Or then again, I might be wrong :p
     
  10. rebmab

    rebmab Chieftain

    Joined:
    Oct 16, 2005
    Messages:
    2
    This formula tells us the cost of a tech. However how does it relate to the number of turns required to research a tech? At the beginning of the game it seems you require 32 turns irrespective of how you set the science rate.
     
  11. Fatal Exception

    Fatal Exception Chieftain

    Joined:
    Sep 16, 2005
    Messages:
    31
    32 turns (or 40 depending on version) is the maximum time to research a tech.

    4 turns is the minimum time to research a tech.

    How it figures out how many turns it takes is determined by how much of your economy's gold goes to research each turn. If something's cost is 500 gold, and you generate 100 gold per turn and have 100% research slider, you'll get it in 5 turns. If you have 50% research slider, 10 turns.
     
  12. Rurik

    Rurik Warlord

    Joined:
    Apr 13, 2004
    Messages:
    111
    Location:
    Levittown, Long Island, NY
    [Sorry for the long "Quote message in reply"...I wanted to make sure readers know to what I am referring.]

    I don't understand the equation...I can't see past the "(1-N/[CL*1.75])" part.

    Once N ("the number of civs on the diplomacy screen that have discovered the tech") is 1 (or greater) then the numerator becomes 0 (or less).

    Dividing [CL*1.75] into 0 (or less) = 0 (or less). Then I take that 0 (or negative number) and multiply it and divide it by other numbers but my end result will have to be 0 (or less)...which I then make even smaller when I subtract "research done do far".

    What am I missing...I know it's there somewhere but I just don't see it.

    Thanks.
     
  13. Jazzmail

    Jazzmail King

    Joined:
    Jul 23, 2005
    Messages:
    710
    Location:
    Gelderland
    lol. :p First divide N by 1.75*CL. Then subtract the outcome.
    You're missing the brackets. (and the division goes before substraction rule)
    N/1.75CL will always be smaller than 1.
     
  14. Rurik

    Rurik Warlord

    Joined:
    Apr 13, 2004
    Messages:
    111
    Location:
    Levittown, Long Island, NY
    It took about 6 sec but I see it now...I knew I was looking at it wrong but couldn't get that 1-N out of the center of my attention. Thanks, Jazzmail.
     

Share This Page