• Civ7 is already available! Happy playing :).

AI trading valuation

This is the formula for research cost for v1.21f . The figures given by it are 100% correct, no more errors or separate rounding formulae ! [dance]

The research cost formula for v1.29f can be found here :

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

Research cost = MM*COST/10 - UP{MM/100 * UP[COST*10N/DOWN(CL*1.5)]} - Research done so far

Research cost and research done so far are in gold.

UP() means round up the figure inside the brackets.
DOWN() means round down the figure inside the brackets.

MM = map modifier =
Tiny 160
Small 200
Standard 240
Large 320
Huge 400

COST = technology cost as specified in the editor.

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

CL = number of civs left in the game
 
Thanks. It seems every time someone says that, the formula turns out to be flawed and I have to correct it. And this time is no exception...

Due to the changes in Difficulty modifiers, I now think that the rounding formula is incomplete. Obviously it makes no difference on Regent and below, but I guess that the rounding formula is now...

ROUNDDOWN(MM * COST * DM * (K - N) / 100K)

with respect to the next integer value of:

ROUNDDOWN[((MM * COST * DM)/100) - (MM * DM/1000)]

Not that it really matters because the rounding formula is inelegant and pretty much useless unless you want to be sure to get the exact value (and sometimes the rounding will be 1 out anyway). I haven't been able to check this out yet, but the above is what it intuitively should be.
 
Wow! What a mathematical talent, this mydisease :)
I study mathematics, and i know it's very hard to construct a formula out of date, not precisely knowing what the variables are, and how the formula should look like. My compliments! :)
 
I wish I still had the data so I could show you how easy it was to find the formula, but it is lost thanks to Bill Gates.

For any given game, MM, DM and COST are constant. This made them easy to find out by varying first map size to find MM, then difficulty level to find DM. COST is in the editor(so is the MM bit, but I didn't realise that until I had already worked them out), so that bit was easy. So, without knowing about the last bit, it was easy to get MM*COST*DM/100 = initial research cost.

This just leaves a more complex variable, which it is fairly obvious varies with the number of civs on the diplomacy screen that know the tech. So then I had to do a lot of data collection, at least 15 different sets of data to get K for each number of civs on the map. This was the only difficult bit because it took ages. I collected every research cost for Pottery, Ceremonial Burial, Bronze Working, The Wheel and Alphabet for every value of N for 2 to 16 civs. If the research cost was above 40 than I had to use simultaneous inequalities to get it (I didn't want to mod up the maximum research time, in case it affected the formula). Getting those 595 values took a while, but I needed a spread of costs (2,2,3,4,5 , the 2,2 serving to check that the rest of the formula is constant) so using only one tech was not acceptable.

Getting K was then surprisingly easy. For the values below 10 it is obvious and after then, I just used the mark at which the research cost is half of the initial research cost as K=2 * this value of N. Of course not all K values are even, so I did use another method if the answer seemed wrong, but this method is difficult to explain without referring to the data and I have insufficient mathematical knowledge to explain it with algebra.

The rounding was definitely the hardest part to get and I got there pretty much by trial and error. However, I have little knowledge of computer programming, so it is only an approximation of the true calculation, not what actually shows up in the code.

AN EPIPHANY

Just now, as I have been writing this I have realised the pattern in K values. The pattern is that the differences between ascending K values are : 1,2,1,2,1,2,1,2,1,2,1,2 (if 5 and 9 civs are rounded up). This greatly simplifies the formula so that it is no longer necessary to list all the values of K. Taking the number of civs left on the map as x, then K=ROUNDDOWN(1.5x) or perhaps even K=1.5x. I can't believe I didn't spot this before. Anyway, I'm off to check the values of K for x=5 and 9 to see if this works. If it does, this might even solve the rounding problems above.
 
Top Bottom