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

Utility: TechCalc

Discussion in 'Civ3 - Utility Programs' started by Grey Fox, Dec 7, 2002.

  1. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    This program is based on mydisease's Tech Research Formula he posted in the Civ3 General Discussion forum. Here!

    TechCalc 2.01
    For all versions of Civilization III. (Patched versions).

    Here's a preview


    ***********************************
    TechCalc Readme VERSION 2.0
    Programmer: Grey Fox, AKA Fredrik Henriksson
    Formula: mydisease
    This is a free program and I hope you enjoy it!

    ***********************************
    This is a program that calculates your tech cost
    based on various factors:
    - Which tech you are researching.
    - Map Size.
    - Difficulty.
    - Number of Civs that you have contact with that has the tech.
    (Including you if you have the tech. Can be checked in the Diplomacy Screen)
    - Number of Civs left (including YOU!)
    - Gold already invested.

    Turns left on the technology is based on:
    - The Tech cost
    - Beakers per turn. (Gold into Science, check in F1 screen in Civ3)
    - and Gold already invested.
    ------------------------------------------------------------
    Thanks to:
    - mydisease for figuring out the Tech Cost formula!
    - anarres for helping me with some problems and suggesting features!
    - kring, for noticing that v.1.01 didn't have an icon.
    - vbraun for suggesting the Gold Lost feature!
    - and everyone that has downloaded the program so far (Although I don't know how many) and to those that will download it in the future. That is my reward, that people uses my program and appreciate it.

    ------------------------------------------------------------
    Revisions
    ------------------------------------------------------------
    Additions v.2.01
    - Added a button for adding the Beakers Per Turn to the Gold Invested edit box.

    Fixes v.2.01
    - Fixed the rounding problems with the Turns Left.
    - Fixed some rounding problems with the Combat Calculator and some other issues.
    ----------------------------------------------------------
    Additions v.2.0
    - Program reprogrammed from the foundation up.
    - Ability to load textfiles with the Tech Names and costs (which makes it possible to change the use of the program, to use it with a mod, Scenario, Conquest, or another version of the game).
    - A Combat Calculator, with everything needed to be useful. :)
    - A simple *regular* calculator, that can add, subtract, multiply and divide.
    - An area where you can keep short notes.
    - You can now see how much gold that will be lost.
    - You can now enter how many turns you've researched.
    ------------------------------------------------------------
    Additions v1.5
    - Added Function to calculate Turns left.
    - Added a "Gold Invested" edit box.
    - Added a new icon.

    Changes v1.5
    - Changed the integer limit on "Nr. of Civs left" and "Nr. of Civs with tech" to 31, from 32.
    - Changed the interface to fit with the new features.
    - Removed the Static Dll file from the .exe-file. (The file only takes about 35 kb now)

    Fixes v1.5
    - Fixed the TechCost calculation formula. It should work almost perfect now.
    - Fixed the Invisible-Icon bug.
    ------------------------------------------------------------
    Additions v1.01
    - Added human error check on number insertions.

    Changes v1.01
    - Changed the interface just a little.

    Fixes v1.01
    - Fixed the Tech List.
    - Fixed the Formula Rounding errors.
    ------------------------------------------------------------

    Please report bugs etc in this thread.
    Suggestions on improvements are always welcome.

    UPDATED: December 16th - 2003
    This file is 19.5 kb
    TechCalc v2.01

    This file is 453 kb
    mfc42.dll - needed for those who can't run the program
     
  2. Toasty

    Toasty Old Guard

    Joined:
    Nov 30, 2001
    Messages:
    3,868
    Location:
    Tampa, FL
    You didn't include the science funding.
     
  3. anarres

    anarres anarchist revolutionary

    Joined:
    Apr 22, 2002
    Messages:
    6,069
    Location:
    www.civ3duelzone.com
    Excellent :goodjob:

    @Toasty, I think it tells you the total cost of a tech. If you want to know number of turns left (as I think you do), then it would need also the exact number of beakers collected so far. The only way to do this is from the savefile, but this is not the intended useage methinks.
     
  4. anarres

    anarres anarchist revolutionary

    Joined:
    Apr 22, 2002
    Messages:
    6,069
    Location:
    www.civ3duelzone.com
    GreyFox, this is excellent. I appreciate the work you have done - I was considering something similar myself as I could never be bothered to work out the numbers by hand and was using a spreadsheet.
     
  5. kring

    kring Asst Cook & Bottle Washer

    Joined:
    Dec 20, 2001
    Messages:
    1,199
    Location:
    Wichita,KS,USA
    Thank you Grey Fox.
     
  6. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    Grey Fox, have you been taking programming lessons from the Firaxian "Play The World" School of Programming? I am no programmer but I can infer the following errors from the results your program gives:

    1. There is a hole in the first half of the tech tree in the middle ages. The missing techs being (after Construction) Monotheism, Feudalism, Engineering, Theology, Chivalry, Invention, Printing Press, Music Theory, Education, Gunpowder, Banking (then Astronomy). However, the techs named after Construction refer to the tech costs of all the techs in the correct order so all the actual costs are offset by 11 backwards (after Construction, before then they are fine).

    2. All costs for Monarch are noticeably too low and costs for Deity sligthly too low. The inverse of both of these cost factors (ie. 1/9 and 1/6) gives recurring roots so I suspect that the error will be due to rounding done by the computer at too early a stage. I know little about programming but can you not do it so the program works outwards from the most internal bracket and this way avoid rounding at this point.

    3. Devaluation rate is not working properly, this being especially noticeable for very early techs. As no. of civs that know the tech increases, cost should decrease in a fairly linear manner, but in fact your program gives big drops. I think the most internal bracket(or is it the most infernal bracket;)) is rounding up to the nearest 1 rather than the nearest .1 and this is causing the problem. Mathematically this part of the formula is better expressed:

    .1 * ROUNDUP[10 * COST * N/ROUNDDOWN(CL * 1.75)]

    Where ROUNDUP and ROUNDDOWN is to the next integer.

    I think the devaluation when other civs have the tech isn't working correctly even taking this into account.

    4. No. of civs with tech cannot be bigger than no. of civs left. You might want to put an internal check to make sure this is the case before calculating.

    5. By giving no. of civs left a range of 1 to 31 (rather than 1 to 16) you are hypothesising that the formula I found for 1.29f is also true for Play The World. It may well be the case, but bear in mind that nobody has tested this hypothesis and I don't have Play The World and so can't test it.

    6. You write "Nr.", bravely defying the general consensus of "No.". Ah well, its a free country.

    7. Its two megs! That's 2/3rds the size of the civ3 executable!

    Sorry if all that was a bit critical.
     
  7. anarres

    anarres anarchist revolutionary

    Joined:
    Apr 22, 2002
    Messages:
    6,069
    Location:
    www.civ3duelzone.com
    Not that GreyFox needs me, but I can answer these:

    4. When I tried putting a greater number of civs with the tech than is in the game, it gave me '0' as an answer. This seems appropriate action in this case. A different logic on the form would make it harder to use.

    7. It has a static DLL built in. This is to ensure that if you don't have the DLL used by GreyFox on your machine it will still work anyway as the necessary parts of the DLL are incorperated in to the file. A smaller version could be built, but then you may not be able to use it. Otherwise complain to micro$oft ;)

    I'm looking forward to the technical issues being resolved as well, I hadn't reached that far in techs in my game yet :).

    Edit: anarres learns to spell :rolleyes:
     
  8. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden

    Hehe, :lol: I'm not perfect :p
    Oops, sorry... copy/paste error here...

    I am working outwards, from the most inner bracket. Check next qoute.

    Yes, the devaluation error is because I totally left out the .1 in the 2nd rounding. The reason for that is because I had no Idea how to implement it.

    Can't number of civs that have the tech be bigger then nr of rivals left, by 1? (because you could do the check you everyone have the tech, including you :) for whatever the reason :p)

    and yes, I was too lazy to implement a check... :p

    Sorry, the range of civs left should be 32. This is because you can play with up to 31 Rivals in PTW (and 24 in Civ3), so if you play with that many you should be able to use the program. And yes I think it will work for PTW, and if it doesn't... well so be it.

    Yes I'm brave! :)
    No, sorry I forgot. It's "Nr." in swedish, and I'm swede... Will change that immediatelly.

    Yep I know... that's because a static library is included which might not be needed in some windows versions, but most probably in the 9x versions... but I will make the next version without it, and we'll see. (I really included it by mistake, but if Mac users can use the file because of it, it's nice having it included...)

    No, don't be sorry.

    The reason to why I released the program was to get feedback from mainly you. Especially about if the formula worked as I did it.

    Well Thank you! :D

    I will get right on the bugfixing!
     
  9. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    So, should I use that instead of:

    ResearchCost = Down((MM/CF)*(Cost-Up.1(Cost*N/Down(CL*1.75))))

    ??
     
  10. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    Ok, I think I fixed all bugs and errors now (exept the static dll).

    I got one question to you mydisease.

    This part of the formula = Up.1, does that mean that 1.45121 should be rounded to 1.5?
     
  11. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    I think you misunderstand the civs left(CL) bit of the formula. This means the number of civs left INCLUDING your civ, NOT the number of rivals. And hence number of civs that have the tech can only equal number of civs left if every civ including you has the tech.

    Yes, that's exactly it. So try:

    ResearchCost = ROUNDDOWN((MM/CF) * (Cost - (.1 * ROUNDUP(10 * COST * N/ROUNDDOWN(CL * 1.75)))))

    In fact, I might change the formula to this. It works out the same and its less ambiguous. Though my maths teacher would kill me if he saw all those round brackets;).

    And I was only joking about "no.", actually I kind of like "nr." better.
     
  12. mydisease

    mydisease Kalokagathian

    Joined:
    Apr 8, 2002
    Messages:
    97
    Though, in fact, I'm being an idiot on this one and you are right no. of civs with the tech can be bigger than no. of rivals by 1.

    And quoting myself:eek: .uuurgh
     
  13. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    You'r sure?

    I'm done with the formula now. All roundings are in, and it's based on your first formula, not the new one you posted here.

    I justed checked it in game. It seems to work quite nice when I included my own civ in the Nr. of rivals left edit box.
     
  14. Stuck_as_a_Mac

    Stuck_as_a_Mac Aptenodytes forsteri

    Joined:
    Apr 4, 2002
    Messages:
    3,936
    Location:
    NYC
    gf: as the name implies, i use macs. i would be happy to test this out for you, as soon as .net comes back on line. just PM me to remind me, seeing as i am a tad *understatement* forgetful
     
  15. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    I'm sorry, CivFanatics.net doesn't work at the moment.

    So I can't upload the newest version.

    I will upload it to my own server, temporarily.


    EDIT: Updated the first post with a new url to the newest version. Beta 1.01.
     
  16. Admiral PJ

    Admiral PJ Chieftain

    Joined:
    Dec 9, 2002
    Messages:
    3
    Location:
    Essex, England
    It works well for me, but I should try the latest version,
    it only allows 2 civs with the tech already I think.

    Would be nice if users could change the techtables used, maybe from reading a text file.. for different mods.
    In my mod I have increased mostof the tech costs as my tiles produce more money as all my laborers make -1 in taxes so cost a lot.
     
  17. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    I will add this in a future version. (I'm still learning windows programming, so don't expect it tomorrow :p)
     
  18. Quillan

    Quillan Monkey Butler

    Joined:
    Jun 2, 2002
    Messages:
    149
    Location:
    Toronto, Canada
    Hey, i haven't looked at the program yet, although i'm sure it will be a great help for the lazy (myself included).

    Just FYI grey, your link for the tourney doesn't work... i'm interested, so pls post other info or PM me!
     
  19. Grey Fox

    Grey Fox Master of Points

    Joined:
    Dec 19, 2001
    Messages:
    8,726
    Gender:
    Male
    Location:
    Sweden
    It's because Civfanatics.net is down. Go to the Tournament forum here at Civfanatics if you want to learn more about the competition.
     
  20. LaRo

    LaRo Dead Rat

    Joined:
    Nov 11, 2001
    Messages:
    492
    Location:
    on the road
    Number of civs you know have the tech...

    Do you include your own civ?

    E.G. I am alone with my brother and I want to sell him astronomy.
    X civs you know have the tech
     

Share This Page