Éa, Dawn of the Mortal Races (phase 1, pre-alpha code development and discussion)

well, at first I thought it was the "divide by turns" that was too harsh.
but then I made all those simili-random calculus and came to a different conclusion:
-the cost cumulated with the casting time is very harsh.

maybe a -0.5% reduction (instead of -1%) would alleviate that for the AI...(as it would look roughly at the next 200turns, and plan based on the next 100) but if my calculus are right.. it would still mean that a foundry cost 500p, and the gain would be valued at 770 (1000 minus the 25 turns delay); so a net worth of 270.. so "only" 11p/turn.
11p/turn of GP work is not so much IMO.
(note that the "worth" of 11/turn is when you condensate prospective gains in the next 200 turns on the 25turns the GP is working : you have a value of almost "11p/turn" during 25 turns by "counting" the future production of an improvement over the next 200 turns.. that's still a small gain.

The AI might try to build foundries this way as 11p/turn is better than 10%prod in almost any other city.

However that won't change that an investment that brings fruits only in 75 turns (as perceived by the player) is still not so interesting.

And if one were to add to that the opportunity cost of not settling the GE in residence... the return on investment of the "foundry" might become even farther away depending on your initial production in the city (you "lost" -due to opportunity costs- 10% during 25 turns. so if you produced 100, the foundry "cost" you 10/turn on top of the 500p=>750p => 71 turns to pay back -the foudnry gives 10(1+10%) once the GE is taken back to residence ==> return on investment : about 96 turns).

It is really possible that the "casting time" is enough of a cost... due to the opportunity cost it involves.
However that would involve balance testing.
 
Well, very interesting ideas and a good structured source. Subscribing and watching the progress. ;)
 
Yes, I'm pretty sure that many of my great works costs are too high and should mostly be down around 100.

In general, I think that most players tend to not time discount enough. Maybe this is an RPG syndrome where everyone talks about "character builds" (your level 20+ end-of-game character) and not what the character actually is for most of the game. Same thing in Civ5 where you are looking to the future too much and the present not enough. If you hang out in the strategy forum for a while, you will see that Deity players really focus on benefit now more that your typical player. Hence, I think my own intuition is a little off. Therefore, I'm purposely setting time discount a little higher than even I'm comfortable with. (Editorial note: the game developers also don't understand time discount, or don't apply it, which is why Deity players don't bother to build much.)

One thing I'm doing wrong is counting Take Residence for only one turn. This works fine if the unit is already there, but no so well if the unit has travel time. So let's say we get 10% of 100 production for 10p from this action each turn. It's a 1 turn action, but let's say we have to travel 5 turns to get there. If I count it only 1 turn, then I have 10 / (1 + 5) = 1.7. It probably wouldn't be worth it to go to the city and only do this for one turn. But if I count it for 8 turns, then I have 10 * (1+0.99+...+0.93) / (8 + 5) = 6.9. Or for 25 turns (same math) gives me 7.3. Or for 50 turns gives me 6.9 again. So it is good to account for the fact that I will be able to do this action more than one turn. I gain a tiny bit considering 25 turns rather than 8, but longer time frames are getting worse because I'm committing the GP for a long time for future gains. (Though longer time frame would be better if the travel time was very long... but I think 25 is probably a good compromise.)

But really, seriously, I don't need an explicit "opportunity cost" here. That's dealt with by the GP comparing marginal values of different options. The opportunity cost, when considering option x, is just the marginal value of option y, where y is the next best option. If y is higher than x (i.e., opportunity cost too high), then we just do y instead. Travel time and casting time (as well as any other costs) just need to be factored into the marginal value of the option we are considering. A GP will do x as long as x is greater than or equal to 0 and y is not greater than x.

Edit: If I wanted to make this even more sophisticated, I could play around with a more complicated time discount function. Perhaps I should relax it to 0.5 or even 0.3 at game start, rising to 1 around turn 150 or so, then start jacking it up really high as some player is obviously approaching victory. The good thing is that I only have to modify one value, TIME_DISCOUNT, to make it dynamic rather than constant.
 
After first try:

Nice, i appreciate the new tech tree. How about getting only the next possible tech visible, while far away techs might only be shown if they are in reach or by recieving them for special?

Btw, as i am playing in German localisation, your info text in tech or other aspects only show in raw code like ' TXT_KEY_EA_ '. Probably you might want to review this before going stable version. Thx for the ' text placeholders ' so i get a view what is on the to-do-list.

As for the leaders, still not catching all of it but looking forward to. So far it is confusing to have them pop-up every turn and give them orders. I ordered a warrior to join a city, but no effect...still wondering. Ordered 2 engeneers to join workers at same turn...well, one shouldn't do so. I could start building 2 wonders but each would have cut off the other if i had done so. Now after building just a single wonder...my workers aren't capable to do improvements any longer. They are still ' engeneers & workers ' without any further use from my view. But probably i do not catch it the right way.

After 97 rounds i still didn't get a naming of my people...but i'm waiting for it every turn. :lol:

Hope the reports might assist your great work.


Edit:

After founding my second city in round 99 i got ctd. Probably i should deactivate other scripts in civ-5, but so far all worked with other mods.
 
I'm sorry I was confusing.

For me the "opportunity cost" question was not for the AI.
It is for the player.
given the number here, I think I will always try to put my GE in residence instead of building the foundry. a RoI delay (return on Investment) of 75 turns (or even 90turns) is WAY too much for me. Unless I have so many GP that I can't settle them all.

Same for the other Great works : the cost being so High, the RoI delay is too important, considering the cost. (10% on all gold in city is way better than any far-reaching trade route/mission that costs 100g/300g).
(that's me doing an opportunity cost. You are right, no need of doing an oppportunity cost if the AI already compares the expected values...)

I expect to settle alll GP.... and do the missions/actions only when all cities have at least one GP in residence. Given the low expected number of GP I think that might never happen. Exception is done with warriors that should be worth more on the front than in a city. that may depend.

For the AI, I think the question is different : if you want them to do the actions, use a smaller time discount. It won't make the action more clever but it would help them build it.

Personnaly, I think your initial -1% is a nice way to represent things. My calculus only show that the gain are too small AND/OR the costs too high;.. not that the evaluating method is wrong.(save for residence as I think you undervaluate it).

(there is only 1 reason why -1% is too high : all casting of great works take 25 turns... so even before evaluating the gain, you already reduce its worth by a lot : 25% if instantaneous gain and 44% (multiplier = 28 instead of 50.5) if the gain is /per turn).
 
After first try:

Nice, i appreciate the new tech tree. How about getting only the next possible tech visible, while far away techs might only be shown if they are in reach or by recieving them for special?
I'll add some toggle arrows to move the tech screen left/right. Unfortunately, the UI system doesn't currently support x any y scroll bars at the same time.

As for the leaders, still not catching all of it but looking forward to. So far it is confusing to have them pop-up every turn and give them orders. I ordered a warrior to join a city, but no effect...still wondering. Ordered 2 engeneers to join workers at same turn...well, one shouldn't do so. I could start building 2 wonders but each would have cut off the other if i had done so. Now after building just a single wonder...my workers aren't capable to do improvements any longer. They are still ' engeneers & workers ' without any further use from my view. But probably i do not catch it the right way.
You should have been able to just move the Engineer off the worker and then you would have a normal worker that can do normal improvements. This is all moot anyway because I'm changing wonders back to a special action done by an Engineer by himself (none of this joining worker nonsense). This was a bad design decision based on the idea that I could let the core engine AI drive the engineer&worker unit around. But that isn't working well so I'm moving away from this system.

After 97 rounds i still didn't get a naming of my people...but i'm waiting for it every turn. :lol:
Did you trigger a "naming condition", such as learning a 2nd tier tech or opening a policy branch? Or maybe you were beaten to one and then you didn't go for a 2nd?

Edit: actually, you should not have been able to build that settler before you had a name. The last version posted has no "popup" to tell you this (I've added it since) so you have to go into the Diplo list and see if you actually have a name. (But for you, that would have been a TXT_KEY_...)

After founding my second city in round 99 i got ctd. Probably i should deactivate other scripts in civ-5, but so far all worked with other mods.
That's almost certainly a bad idea. This mod just affects too many systems.

Anyway, this is what you get with an alpha. And Éa is not even that yet. (Save/load is currently buggered, among other things...)
 
Most civs will have something like 3 - 5 GPs at any given time
4 GPs * 10 Civs * 0.1 seconds per GP = 4 seconds per turn; pretty significant for just one feature in a mod that will be making many other AI adjustments too.
I guess I have nothing useful to add here though.

Your valuation approach seems sensible.

but a linear "loss of value over time" function should work. This should probably be somewhere in the range of 1% per turn, so that a thing is counted as half-value if the payoff is 50 turns in the future
Why linear? Discounting should be mutiplicative; a constant discount rate. Maybe I'm just biased by all my training as an economist, but additive discounting means you get a proportional discount rate that is changing over time; you lose 1% on the first turn (100->99), but you lose 50% on the second to last turn (2->1). It leads to a non-stationary process, which is really unfortunate; if the idea is that something will halve in value over 50 turns, then it should be the case that 100 today is worth the same as 200 was 50 turns ago, and that it will behave the same way (I should be indifferent between them).
But in your model it isn't; 100 today from a new effect will drop to 99 tomorrow, but 200 from 50 turns ago will drop to 98 tomorrow; they're being discounted at a different rate. So I should really value the 100 from a new benefit today *more* than I value 200 from 50 turns ago.
Or equivalently, if I am choosing between 100 today or 50 in 50 turns from now, under your additive system these are not equal; the 50 will drop to 49.5 on day 51, but the 100 will drop to 49 on day 51.
The time preference of money is central to economics and finance, the math all already exists, an additive system risks all kinds of distortions.

So please: use multiplication (eg have a discount factor of 0.99), not subtraction.
 
So please: use multiplication (eg have a discount factor of 0.99), not subtraction.
I'll be happy to do this if you provide an equation for me. I know this is rudimentary but I'm too many years from math class (and my series approach isn't going to work if the value never goes to zero). Here is the problem:

value now = f(turns to complete, instant payoff, per turn payoff, discount factor)

What's the function?
 
for instant payoff :
value now = Value*0.99^(turns to complete-1) (but maybe exponents are hard to make).
("turn to complete" is 1 means that on turn 1 you get the yield. if turn to complete = 2, the yield is valued at 0.99)

for trade route : (sum of X valued from the time of completion up to x valued at time of end of calculation).
it means : first yield of the trade route is ON the turn of the completion ; and the calculus ends after "end turn of completion")
Value now = Value*([0.99^(turn to complete-1)-0.99^(end turn of calculation+1)]/(1-0.99))

-if you say "end of calculation" is "100 turns after completion" (to have 100 turns of trade route yield) you can simplify it into
Value now = Value*([0.99^(turn to complete-1)-0.99^(turn to complete-1 +100+1)]/(1-0.99))
Value now = Value*(0.99^(turn to complete-1)[1-0.99^(100)]/(1-0.99))
Value now = Value*(0.99^(turn to complete-1)[1-0.366]/(0.01))
Value now = Value*(0.99^(turn to complete-1)*63.4))

-if you say : the AI plans only for the next 100 turns ; if it is 50 turns until completion, the AI will calculate the yield only on the remaining 50turns.
then Value now = Value*([0.99^(turn to complete-1)-0.99^(101)]/(1-0.99))
Value now = Value*([0.99^(turn to complete-1)-0.3623]/(0.01))

If you want a bigger impact of time decrease, use 0.98 or 0.97 instead of 0.99 (in base formulas)
(EDIT : 0.98 is very very steep ; value in 100 turns is 13.5% of original value, value in 200 turns is 1.7% of original value (it was respectively 37% and 13.5% for 0.99)
If "complete NOW" is equal to "turn to complete" =0 ... please change (turn to complete -1) by (turn to complete) in the preceeding equations.

Spoiler complicated alternative if exponent cannot be used for your calculations :
Otherwise, I found that Value now= Value*(1-(turns to complete)/M)/(1+(turns to complete)/100)
This function is something that kinda work with almost same decrease.
with M= 400, you have almost the same values...
differences :
an increased time discount (up to +5% [EDIT : 0.66 instead of 0.69]at turn 37) then
equal time discount at turn 110 (0.40);
decreased time discount from turn 110 : at 200turns : 18% less time discount [Edit : 0.166 instead of 0.133] ; 23% at turn 253 : 0.10 instead of 0.077, : 20% at turn 300 (0.61 instead of 0.59)).

For trade routes you can calculate in 2 times :
for a trade route : W/per turn valuing the the first 100 turns of yield (and not yield in next 100 turns) using either formula could be W*60 (for 200 turns of yield: W*85)
1) value of 100 (or 200) turns of yield = W *63 or W*85
2) Value now = f(value of 100 (or 200) turns of yield).


Edit: it doesn't matter if the value never reaches 0.
It will always be compared to a Non-zero value (become resident in closest city)
 
if you use 0.986 as a "time decrease factor" in the first formula (with exponents) it is fun :

50 turns : perceived value is close to 1/2 (0.501)
100turns: perceived value is close to 1/4 (0.248)
150turns: perceived value is close to 1/8 (0.122)
200turns: perceived value is close to 1/16 (0.061)
250turns: perceived value is close to 1/32 (0.029)
300turns: perceived value is close to 1/64 (0.0147)
... fun no ?
 
(and my series approach isn't going to work if the value never goes to zero)
Why? All you need is a value function that maps a nominal yield and a game turn into a present value.

And even for a series, the value doesn't need to become, it just needs to converge to zero in the limit as t-> infinity.

By example:
1 + 0.5 + 0.25 +0.125 + ..... = 2

You can also just sum values out until the final game turn; the mod has a finite number of turns, and there are formulae for finding the sum for finite or infinite convergent geometric progressions.
http://en.wikipedia.org/wiki/Geometric_progression

value now = Value*0.99^(turns to complete-1)
Right.

If I finish a trade route that will give me X gold per turn forever, and I have a discount factor of 0.99, then the value of that trade route is X + X*0.99 + X*(0.99)^2 + X*(0.99)^3 + .... = X / (1 - 0.99) = 100X

If you want to sum up to the final game turn, you can do that instead, the value will be :
X + X*0.99 + X*(0.99)^2 + X*(0.99)^3 +... + X*(0.99)^(N-t) = X[1 - (0.99)^(N - t + 1)]/[1-0.99]
where N is the total number of game turns in the mod and t is the current turn counter.
 
If I finish a trade route that will give me X gold per turn forever, and I have a discount factor of 0.99, then the value of that trade route is X + X*0.99 + X*(0.99)^2 + X*(0.99)^3 + .... = X / (1 - 0.99) = 100X

If you want to sum up to the final game turn, you can do that instead, the value will be :
X + X*0.99 + X*(0.99)^2 + X*(0.99)^3 +... + X*(0.99)^(N-t) = X[1 - (0.99)^(N - t + 1)]/[1-0.99]
where N is the total number of game turns in the mod and t is the current turn counter.
correct me if i'm wrong: those values are only for trade routes that are available instantly... and not after a delay.
 
Well, resorting to wiki for some math, the per turn yield is an infinite geometric series that can be solved exactly (no need to set a turn horizon at all):

1 + r + r^2 + r^3 + ... = 1/(1 - r)

If I set r = 0.99, then a trade route of 10 gpt starting now is worth 1000. If it starts in 8 turns, that becomes 1000 * r^8 = 923. Using r = 0.986 (which gives half value at ~50 turns), I get 714 and 638. That seems reasonable. Let's see if I can put it together into one equation:

r = discount rate
t = turns until complete
i = instant value when complete
p = per turn value when complete
v = marginal value

v = (i + p / (1 - r)) * r^t


If you have an "instant" payoff of 500g, then you have t=0 which just solves to 500. If it's next turn (t=1) then it is just 500 * r. If 8 turns, then 500 * r^8.

As I said in an earlier post, I think I might alter r as the game goes on. Using r = 0.995 gives you a half-value at ~140 turns, which may be reasonable very early in the game. That could lower to 0.986 (half-value at ~50 turns) over the first 100 turns. Then it could stay at that level until someone is clearly approaching a victory condition, where we could jack it down as low as 0.96, half-value at ~17 turns.

Edit: On second thought, I'm not so sure about the early game thinking above. An instant payoff is quite powerful in early game, arguably more than later. So I think I'll just start at 0.986. But lowering it near endgame seems reasonable.

Edit2: Arghhh... I forgot to divide by turns committed above. Will fix in next post.
 
I would correct (at least) the equation into:

v=(i + p / (1-r)) * r^(t-1)

indeed : I think it is very probable that instant is in fact: "completion in 1 turn" (see worker mechanics : if "irrigation in 1turn" : irrigation is given during this present turn or at least at END_turn.)

Otherwise I don't understand your remark on "divide by turns commited".

then : very very nice combination of the instant and trade route calculs... why didn't I see it? stoopid me.

last : Maybe "r" would have to change with speed of game (quick/normal/marathon...etc).
 
My equation above is wrong because I didn't deal with costs, which include both direct "construction cost" (which some of my great works have) and the cost of the GPs time. Also, some per turn effects (both + and -) might have an explicit end time. GP time (including construction cost and travel time) is always going to be a denominator. Great Work costs are taken on a per turn basis spread out over construction time (and this negative can be time discounted just like a positive). For something like Take Residence, we can just set "build time" to some number like 8 and then give positive per turn payoff during that build time.

Let me do this first without travel time. Assume we are at the target location:

r = discount rate
t = build time
b = per turn gain/loss during build time (a cost is just a negative)
i = instant gain/loss when complete
p = per turn gain/loss when complete
v = marginal value

v = [(i + p / (1 - r)) * r^t + b/(1 - r) - b/(1 - r) * r^t ] / t

The b/(1 - r) - b/(1 - r) * r^t part looks complicated but is simple. It is just gain/loss value of per turn b run out from now to infinity, minus gain/loss value of per turn b run out from t to infinity. The /t on everything is just accounting for the GP's time.

Now let's account for travel turns to get to the target, call it g. The value part is pretty easy: we can just take the value equation above (everything inside []) and put it g turns in the future. So just multiply by r^g. This costs the GP time so we also need to add it to the denominator.

g = travel time to get to target

v = [(i + p / (1 - r)) * r^t + b/(1 - r) - b/(1 - r) * r^t ] * r^g / (t + g)

Anyone what to check my math?
 
it seems ok, but it depends on the time of the "cost".
is the 300 payed up front (trade mission?)
if the 500 are payed at b=20p/turn during 25 turn your calculus seems ok
is the B payed infull at completion ? then B needs to be counted as -i

I propose

v = [(i + B' + p / (1 - r)) * r^(t) + b/(1 - r) - b/(1 - r) * r^(t)+ B ] * r^(g-1) / (t + g)

with B = cost payed upfront when "initiating" the action
B' = cost payed cash after completion of the "action"

g will never have value of "0" :
If move can be accomplished in current turn, g=1 (need to verify : "can cast after moving") ;
so at least g has to be replace (in exponents) by "g-1".

Maybe it is needed for t also if "instant" is in fact : t=1 (in such case, t+g should be replaced by t+g-1)
 
if you use 0.986 as a "time decrease factor" in the first formula (with exponents) it is fun :

50 turns : perceived value is close to 1/2 (0.501)
100turns: perceived value is close to 1/4 (0.248)
150turns: perceived value is close to 1/8 (0.122)
200turns: perceived value is close to 1/16 (0.061)
250turns: perceived value is close to 1/32 (0.029)
300turns: perceived value is close to 1/64 (0.0147)
... fun no ?
Wouldn't a trade route give more gold as the game progresses though? (Or it should.) Because, you have to think in terms of how a trade route works in real life. The longer a trade route is open, the safer it theoretically becomes; and therefore the more profitable it is for merchants to use it. Also, with technological advances, it becomes even more profitable. (For instance, when automobiles were invented, it took significantly less time to get from, say China to Greece. Then, planes made that time even less. Etc.) As a result, shouldn't the function increase as time goes on? Instead of decreasing?
 
Wouldn't a trade route give more gold as the game progresses though? (Or it should.)
Which is why this whole exercise is kind of goofy anyway. I'm trying to derive an exact equation but I'm going to be throwing a lot of approximations at it.

However, the time discount concept means that we are mostly looking to near term and later doesn't matter so much. Exact per turn yield now is an OK proxy in most cases for what it will be for the next 30 turns or so.

There is one fudge factor already built into my code. That is if a city is new (< 40 turns) and there is 1 nearby food resource, then it is assumed that it will grow to 5. The per turn value spit out by TestEaAction(<trade route>) is actually based on that. (the code for this "city potential" was in for other reasons, but I piggy back the trade route estimate on that) Note that TestEaAction can throw out estimations rather than actual current values (its only for ai anyway)...or it can if I add the code for it.



with B = cost payed upfront when "initiating" the action
B' = cost payed cash after completion of the "action"

I don't actually have these. It is either spread out over the build time (count it as negative b) or an instant cost that can be subtracted from i. [I should have said above that b = -total cost of build / build time if we are considering construction cost; but it could also be a positive number during "build time" if we are considering Take Residence]

g will never have value of "0" :
g can be zero if I'm on the plot and I have movement. However, t is always > 0 because any action that gives us something "uses" the GP's movement (t=1). That's what I mean when I say "instant." Some of these might really be "instant" payoff versus next turn, but I'm not going to sweat that small difference. If something has completion time = 8, that just means that the unit's movement will be used up 8 times.
 
well, IIRC, Pazyrk plans for "trade routes" (opened by GM) to produce 1%more every 10 turns...showing the increased security.
(however, there will be greater increases due to the evolution of the cities size)

However, the "perceived values" you quoted are values that will be used to try to teach the AI to estimated if it is worthwhile to send its GM to build the trade route in the first place.

their purpose is to make the AI estimate that establishing a 10g/turn trade route with the foreign city you are already in is better than a putative trade route of 15g/turn in another city.. but you have to move 25turns before getting there.

so trying to "see" if the trade route will grow latter is another difficulty.
further, if the city reduces in size... the trade route will bring less. and you have no way to predict :D
some approximations are needed.
 
Which is why this whole exercise is kind of goofy anyway. I'm trying to derive an exact equation but I'm going to be throwing a lot of approximations at it.
Well, if you're familiar with Calculus, may I recommend you model an increasing series that is convergent within only certain values? I'd probably try a powers series (http://en.wikipedia.org/wiki/Power_series). In other words, the equation only works between say the values of 1 and 50. (Numbers picked arbitrarily.) That way, you can estimate a partial sum of the series and therefore determine whether the increase will be satisfactory.
 
Top Bottom