Foreign trade routes mechanics?
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Foreign trade routes mechanics?
It's fairly clear that if you have trade treaties with multiple foreign powers, the theoretical benefit from additional trade partners is reduced. (For instance, signing a trade charter with the Ashdar Empire, which theoretically should have been worth 21 foreign trade routes, increased my actual number of trade routes by... six, I believe, but the exact number slips my mind.) This is actually something that's perfectly fine in my book, but the actual way it's calculated is opaque to me and not documented in-game.
So, I have questions, which Sven or Arioch can answer if they wish.
1) What is the formula determining the theoretical maximum benefit from trade charters and research charters with foreign powers? The math that would return the '21 foreign trade routes' in the previous example.
2) How does the game determine how much actual practical benefit you gain from all trade or research charters combined? The math that results in the six (or whatever the actual single-digit value was) new trade routes added to my actual total of trade routes.
I'm actually quite happy with the practical experience of trade and research charters now (and am no longer having to watch everybody else I trade with get significantly more income from their trade treaties with me than they get from all other sources combined, pushing them up from deficits to multiple hundreds of surplus, which always struck me as a touch silly- now I get to see them get real benefits, but real benefits that don't completely swamp the rest of their economy). I'm just curious about the nuts and bolts of the system, which aren't really explained anywhere.
So, I have questions, which Sven or Arioch can answer if they wish.
1) What is the formula determining the theoretical maximum benefit from trade charters and research charters with foreign powers? The math that would return the '21 foreign trade routes' in the previous example.
2) How does the game determine how much actual practical benefit you gain from all trade or research charters combined? The math that results in the six (or whatever the actual single-digit value was) new trade routes added to my actual total of trade routes.
I'm actually quite happy with the practical experience of trade and research charters now (and am no longer having to watch everybody else I trade with get significantly more income from their trade treaties with me than they get from all other sources combined, pushing them up from deficits to multiple hundreds of surplus, which always struck me as a touch silly- now I get to see them get real benefits, but real benefits that don't completely swamp the rest of their economy). I'm just curious about the nuts and bolts of the system, which aren't really explained anywhere.
- sven
- Site Admin
- Posts: 1621
- Joined: Sat Jan 31, 2015 10:24 pm
- Location: British Columbia, Canada
- Contact:
Re: Foreign trade routes mechanics?
It's not really that easily explained in English. In code, the core bits are here:nweismuller wrote:I'm just curious about the nuts and bolts of the system, which aren't really explained anywhere.
Code: Select all
function Empire.trade_charter_routes(empire,other)
local r = max(2, round | .35 * other.raw_trade_capacity)
if empire.species=='phidi'
r*=1.5
end
return round | r
end
function EmpireProperty.total_foriegn_trade_routes(empire)
local rval=0
for _,other ; all_empires
if trade_charter(empire,other)
rval+=empire:trade_charter_routes(other)
end
end
local foriegn_trade_cap in empire
return min(foriegn_trade_cap, rval)
end
function EmpireProperty.foriegn_trade_cap(empire)
local raw_trade_capacity in empire
local charters=0
for i,e in voting_empires()
if trade_charter(e,empire)
charters+=min(1,e.raw_trade_capacity/raw_trade_capacity)
end
end
return round | (.4+.1*charters)*raw_trade_capacity
end
So, basically, the math is about the simplest model I could come up with for a trade system that seems roughly "intuitive". I.e., new trading partners are never completely useless, but, in general, you can't benefit much more from foreign trade than makes sense given the size of your own economy, and their is a fairly steep diminishing returns effect that comes in to play if your markets are already swamped with alien goods.
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Re: Foreign trade routes mechanics?
I'm seeing a bit in code where Phidi empires either give a bonus to the number of trade routes they give their partners, or get a bonus in the number of routes they get from partners, and I'm not sure what applies since I'm not sure what the scope of empire.species is here. Which is it?
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Re: Foreign trade routes mechanics?
... checking the code against my game, I must not be following the code correctly. I, as the Phidi Combine, currently have 223 available trade routes, and have a reported bonus of 77 coins per turn from foreign trade from the 216 routes I am currently working. As I understand that, this means I have 146 domestic routes and 77 foreign routes available. I have trade charters signed with the Ashdar Empire, the Ashdar Colonials, the Orthin Conference, and the Tinkers, with reported yields of 23 routes, 23 routes, 39 routes, and 17 routes respectively, for a total theoretical yield of 102 routes. As I understand the code, my actual number of foreign routes with four trade charters should be 80% of my domestic routes (116 or 117, depending on rounding) or the total theoretical yield, whichever is less. If I assume the cap is instead on the *total value* of foreign routes, that still doesn't help, because I'd then expect a cap of 58 or 59 routes, half of that 116 or 117 routes.
What am I missing?
Edit: A little rechecking makes it look like I can get the expected 116 cap by multiplying my observed cap of 77 by 1.5, which is still confusing to me, but at least makes it so there's some relation between the observed numbers and the numbers I expected. Is it somehow related to the Phidi trade bonus, then?
What am I missing?
Edit: A little rechecking makes it look like I can get the expected 116 cap by multiplying my observed cap of 77 by 1.5, which is still confusing to me, but at least makes it so there's some relation between the observed numbers and the numbers I expected. Is it somehow related to the Phidi trade bonus, then?
- sven
- Site Admin
- Posts: 1621
- Joined: Sat Jan 31, 2015 10:24 pm
- Location: British Columbia, Canada
- Contact:
Re: Foreign trade routes mechanics?
Well, the code doesn't actually guarantee you 80% with four charters, it can get scaled back significantly if your economy is much larger than your trading partner's. I would imagine that's part of what's happening here. For example, if the Tinkers are giving you 23 routes, that suggests that their domestic trade capacity is about 23/.35=66. That in turn means that their bonus to your trade cap will only be (66/223)*.1 = 3% (rather than the max 10% you'd get if their domestic trade capacity was as big as yours).nweismuller wrote:... checking the code against my game, I must not be following the code correctly. I, as the Phidi Combine, currently have 223 available trade routes, and have a reported bonus of 77 coins per turn from foreign trade from the 216 routes I am currently working. As I understand that, this means I have 146 domestic routes and 77 foreign routes available. I have trade charters signed with the Ashdar Empire, the Ashdar Colonials, the Orthin Conference, and the Tinkers, with reported yields of 23 routes, 23 routes, 39 routes, and 17 routes respectively, for a total theoretical yield of 102 routes. As I understand the code, my actual number of foreign routes with four trade charters should be 80% of my domestic routes (116 or 117, depending on rounding) or the total theoretical yield, whichever is less. If I assume the cap is instead on the *total value* of foreign routes, that still doesn't help, because I'd then expect a cap of 58 or 59 routes, half of that 116 or 117 routes.
It looks to me like your observed trade cap is about 52% of your domestic trade capacity. And that makes sense, if you're getting about a 3% trade cap boost from each of your 4 trading partners.
So, long story short -- it looks like your economy is huge relative to the other empires, which is why you're seeing such a relatively small foreign trade income.
- sven
- Site Admin
- Posts: 1621
- Joined: Sat Jan 31, 2015 10:24 pm
- Location: British Columbia, Canada
- Contact:
Re: Foreign trade routes mechanics?
I believe this bonus benefits people trading with Phidi, rather than the reverse. So, charters with Phidi can be 50% more lucrative than charters with other races.nweismuller wrote:I'm seeing a bit in code where Phidi empires either give a bonus to the number of trade routes they give their partners, or get a bonus in the number of routes they get from partners, and I'm not sure what applies since I'm not sure what the scope of empire.species is here. Which is it?
- sven
- Site Admin
- Posts: 1621
- Joined: Sat Jan 31, 2015 10:24 pm
- Location: British Columbia, Canada
- Contact:
Re: Foreign trade routes mechanics?
Oh, wait, my math is wrong here. Our guess is that your domestic trade capacity is actually 146, so the bonus to your cap from the Tinkers should be (66/146)*.1= 4.5%. That means the numbers don't quite add up again... as I'd project your trade cap at closer to 58%, rather than the observed 52%. There's probably some other factor in here I'm still missing as well... Um, if we opened up your game inside a Visual Studio Code debugger, we could figure this out pretty quickly... Feel free to send me an uploadsven wrote:That in turn means that their bonus to your trade cap will only be (66/223)*.1 = 3% (rather than the max 10% you'd get if their domestic trade capacity was as big as yours).
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Re: Foreign trade routes mechanics?
game_9627 uploaded.
Edit: From what you said, looks as if the line I wasn't taking into account was 'charters+=min(1,e.raw_trade_capacity/raw_trade_capacity)'. I think because my brain was reading it as 'raw trade capacity divided by raw trade capacity', and parsing it out to 1.
Edit: From what you said, looks as if the line I wasn't taking into account was 'charters+=min(1,e.raw_trade_capacity/raw_trade_capacity)'. I think because my brain was reading it as 'raw trade capacity divided by raw trade capacity', and parsing it out to 1.
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Re: Foreign trade routes mechanics?
So, out of curiousity, what's the something else happening that makes the numbers not match what you expected?
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Re: Foreign trade routes mechanics?
Ever get a chance to check on that?
- sven
- Site Admin
- Posts: 1621
- Joined: Sat Jan 31, 2015 10:24 pm
- Location: British Columbia, Canada
- Contact:
Re: Foreign trade routes mechanics?
Sorry, got distractednweismuller wrote:Ever get a chance to check on that?
The problem with our earlier math is that I misread how the Phidi trade route bonus works. I'd told you I though it added a 50% bonus to the max routes gained from other empires trading with Phidi, but, I was wrong. Whatever my intention was when I coded it up, it looks like it's actually adding 50% to the routes gained by the Phidi themselves. That means that if you want to estimate raw trade capacity from the number of routes reported in the diplomatic screen, and you're playing as Phidi, you need to divide by 1.5*.35. So, for example, the true raw trade capacity of the Tinkers is about 17/(1.5*.35). Make that adjustment to my earlier math, and I suspect the numbers will all balance properly.
Now, high level, I think it's fair to ask if this totally undocumented 50% bonus to the Phidi's foriegn trade route production is actually a thing that it's wise to have inside the game. Right now, I think Phidi are probably the strongest race in the game, and including a fairly strong undocumented economic bonus, ontop of all their other (better documented) very strong economic bonuses is maybe a place where I've taken their theme too far.
That said, I do *enjoy* playing Phidi as they are now, so I'm hesitant to nerf this...
edit: In practice, I bet it's most often going to be the trade cap that really matters for Phidi players, rather than the hypothetical max income from any one treaty, and the Phidi aren't getting a bonus to their foreign trade cap, relative to the other races. So... I'm not certain this hidden bonus is really helping them that much in real games.
-
- Posts: 424
- Joined: Wed Apr 29, 2015 2:33 am
Re: Foreign trade routes mechanics?
I've been enjoying playing the Phidi quite a bit myself. (And, as you've likely been able to tell by my uploaded games over the development cycle, lean heavily into their 'peace-loving' theme most of the time.) If there are other players who report finding the Phidi frustrating to play against, maybe you should look into tuning them down, but I'm happy with where they're at from the perspective of a Phidi player.
Edit: And yes. The trade cap is something I am frequently dealing with as a Phidi player.
Edit: And yes. The trade cap is something I am frequently dealing with as a Phidi player.
- sven
- Site Admin
- Posts: 1621
- Joined: Sat Jan 31, 2015 10:24 pm
- Location: British Columbia, Canada
- Contact:
Re: Foreign trade routes mechanics?
Yeah, AI's don't really play Phidi the same way a player does -- in particular, the AI doesn't use the influence system, so all that super-powerful Opil influence actually does nothing for them. As a result, I don't think there's a need for a nerf for the purposes of making the Phidi AI's weaker.nweismuller wrote:If there are other players who report finding the Phidi frustrating to play against, maybe you should look into tuning them down, but I'm happy with where they're at from the perspective of a Phidi player.
Of the AI's, the thing most players seem to find most frustrating are the Orthin and their super-tanky Battle Shield designs...