Firaxis: Fix trade

TheNiceOne

Emperor
Joined
Feb 6, 2002
Messages
1,372
Location
Norway
Hi, after several discussion threads about trade, I think I've got a solution that should be so easy to implement that Firaxis could fix it in the next patch.

The suggested solution will adress two issues. One is that people don't understand why the AI "will never accept" a trade, and the other is the fact that your per turn goods is simply makes any trade unacceptable if the AI is to give something instant and you have a bad reputation.

The first issue can be fixed by a better advisor. They simply need to change the advisor text so that it says something else than "they will never accept such a deal" in the following cases:
1) If you offer more gpt than your income, it should say something like "They will not accept since they don't think you can pay this for 20 turns."
2) If you ask for more gpt than their income, it should say something like "They will not accept since they're afraid of going bancrupt".


The second issue has been discussed in several threads lately, and I've just given a suggested solution in this thread, but I thought it deserved its own thread here, so I repeat it:


If I have screwed an AI, afterwards I can still make three of the four base trade types. I can:
1) Give per turn goods (resource, gpt) and receive per turn goods.
2) Give instant goods (gold, tech, map) and receive instant goods.
3) Give instant goods and receive per turn goods.

But the only thing the AI will never accept is that I:
4) Give per turn goods and receive instant goods.
The latter is the only way that the AI can be screwed, and is also the only trade type the AI will not accept after having been screwed once.
However, there is also combinations of these trade types, where one side (or both) gives both instant and per turn goods.

The problem is that when you have broken one deal, your per turn goods are considered worse than worthless in any deal where the AI gives instant goods.

This should be fixed by instead of just not accepting such a deal, the AI should modify your per turn goods by a multiplier between 0 and 1, depending on your reputation.

This is something Firaxis could (should?) do relatively easily, but its important that only trades of type 4) (and combinations) are modified this way. The problem arises when both sides gives instant goods and per turn goods. In that case they need to compute the difference in per turn goods given, and only modify this difference by the reputation modifier - not modify all of the per turn goods.

Ex:
Civ A and B wants to make a trade. A's reputation is 0.5 and B's reputation is 0.9.

1) If both trades per turn goods only, the values are unmodified.
2) If both trades instant goods, the values are unmodified.
3) If A gives instant goods and B gives per turn goods, B's goods is multiplied by 0.9, so B need to pay an interest rate of 11.1%.
4) If A gives per turn goods and B gives instant goods, A's goods is multiplied by 0.5, so A needs to pay an interest rate of 100%.
5) If A gives instant goods and per turn goods and B gives instant goods, the per turn goods from A is multiplied by 0.5, but the instant goods is unmodified.
6) If A and B both give per turn goods and instant goods, the following must be done. First must the difference of the unmodified trade values of the per turn goods be computed. Say that A gives 10gpt and B gives a luxury worth 8 gpt. This means that A gives 2gpt more than B. So this deal will be treated as 5), whith A's additional 2gpt multiplied by 0.5.

Let me do an even clearer example for 6.
B has a tech worth 500 gold and a luxury worth 8gpt. A has 400 gold and will pay the rest by gpt, i.e. enough gpt to pay for the remaining 50 gold for the tech and for the luxury. The gpt needed will then be 18 gpt, in addition to the 400 gold.

The computation is: (18gpt - 8gpt)*0.5 (A's modifier) = 5gpt.
So A is considered paying 400 gold and 5gpt for B's tech worth 500 gold, which is exactly the same sum. This is in addition to the 8gpt A pays for B's luxury.

If A's reputation was spotless (a modifier of 1), it would only have to pay 13 gpt, since (13gpt-8gpt)*1 = 5gpt as well.


So Firaxis, listen up, I've outlined the code for you. Now you implement it in your next patch. :king:
 
I second this motion!
 
Also nice to have would be a fix for the problem of the player getting the blame for a broken trade where it is NOT the player's fault. E.g. Trade route broken by someone else's war.
 
Originally posted by TheNiceOne
Let me do an even clearer example for 6.
B has a tech worth 500 gold and a luxury worth 8gpt. A has 400 gold and will pay the rest by gpt, i.e. enough gpt to pay for the remaining 50 gold for the tech and for the luxury. The gpt needed will then be 18 gpt, in addition to the 400 gold.

The computation is: (18gpt - 8gpt)*0.5 (A's modifier) = 5gpt.
So A is considered paying 400 gold and 5gpt for B's tech worth 500 gold, which is exactly the same sum. This is in addition to the 8gpt A pays for B's luxury.

If A's reputation was spotless (a modifier of 1), it would only have to pay 13 gpt, since (13gpt-8gpt)*1 = 5gpt as well.

Now, am I missing something?

* B offers 500 gold (tech) and 8 gpt (lux)

* A has 400 gold and enough gpt

* A needs to pay 100 gold (not 50) and 8 gpt with his gpt. This would mean 100/20+8=13 gpt

* A's modifier is 0.5: 0.5/13 = A needs to pay 26 gpt

* A pays a total of 400+26*20=920 gold for something worth 500+8*20 = 660 gold.

Let's for now forget the fact that gpt payments need to be discounted by some factor.

Yes? No?
 
Originally posted by TheNiceOne
So Firaxis, listen up, I've outlined the code for you. Now you implement it in your next patch. :king:

I am for this, too.

Code:
bool AI::tradeReputationCheck(
  double theirInstantOffer,
  double theirPerTurnOffer,
  double theirReputation)
{
  double tradeBalance;
  double theirSafePerTurnOffer;
  double theirDubiousPerTurnOffer;

  if (ourPerTurnOffer > theirPerTurnOffer)
  {
    //us cheating them is no problem...
    theirSafePerTurnOffer = theirPerTurnOffer;
    theirDubiousPerTurnOffer = 0;
  }
  else
  {
    //they might try to cheat us...
    theirSafePerTurnOffer = ourPerTurnOffer;
    theirDubiousPerTurnOffer = theirPerTurnOffer - ourPerTurnOffer;
  }

  tradeBalance =
      theirInstantOffer
    - ourInstantOffer
    + theirSafePerTurnOffer * 20
    + theirDubiousPerTurnOffer * theirReputation * 20
    - ourPerTurnOffer * 20;

  return tradeBalance >= 0;
}

Now copy&paste the above and compile the patch. :)

[Ed.: !#%&%. 5th time I edit this d**n post... No wonder most software is so buggy...]
 
Originally posted by Hurricane

* A needs to pay 100 gold (not 50) and 8 gpt with his gpt. This would mean 100/20+8=13 gpt

* A's modifier is 0.5: 0.5/13 = A needs to pay 26 gpt

Actually the 8gpt for the 8 gold luxury is a "safe deal". If the trade gets cancelled then both the 8 gpt and the luxury gets cancelled. This is why TNO made the distinction between "gpt for gpt" and "gpt for instant goods". Thus the calculation goes:

100 gold / 20 turns = 5 gpt
reputation = 0.5 => 5 gpt / 0.5 = 10 gpt
total: 10 gpt + 8 gpt = 18 gpt.

=> TNO calculated right.

Let's for now forget the fact that gpt payments need to be discounted by some factor.

You are right on this. I think, though, that TNO meant that in addition to all other modifiers you then finally apply the reputation modifier.
 
Darn, I answered on the other thread while this would have been much better to put my post here.
Well never mind, time for cut'n'paste :)

A good system would be if each ressource could give you a given number of "use" each turn. For example, a luxury ressource could supply (let's take a fictionnal number just for the sake of the example) 100 population points. If you control 5 sources of sikls then, it's not "5 sources", it's "500 population points". Then you would be able to make trade that make sense ("I give you 200 luxury points, you give me 200, but as I've only 50 population points, rather than giving me 200 units of the same luxury, you give me 50 of each").

Being more detailed :
Luxury resources would supply a given number of population. If you have a source that supply 100 pop points and have 15 size 10 cities, 10 of them will receive the luxury resource, and 5 of them won't.

Strategic resources would supply a given number of shields each turn. Each unit that requires strategic resource(s) will use them by being built (example : a tank require oil and rubber, hence a city that have a production output of 15 will consume 15 units of oil and 15 unit of rubber each turn.
There would be also the "maintenance cost" : each unit requiring resources for its construction would also need one unit of them each turn to be able to move (a tank would need one unit of rubber and oil each turn, or its movement fall to 0) and to heal. Could simulate realistically the problems faced by countries whose supply in oil are not sufficient to fuel their armies, like Axis in the WW2, and would also make a huge army costly.

Well, feel free to develop, but I think this could improve enormously the game. Having huge empire needing more than one mere source for their total supply would be a good thing :)
 
Originally posted by Hurricane
Now, am I missing something?
Pemboke answered this as I meant it. It is only A's gpt part that pays for the tech that gets modified by 0.5. The gpt part A pays for the 8gpt worth luxury is taken out from the modifiction just as the B's luxury is taken out, since those two per turn parths effectively cancels each others if the deal is broken.

If you didn't start the calculation by taking out these two, then you would get impossible trades where A demands that B pays an overprice of 11.1% on the luxury while B demands that A pays an overprice of 100% on the gpt.

Let's for now forget the fact that gpt payments need to be discounted by some factor.

Yes? No?
Yes, but this could easily be solved by having the reputation modifier going from 0 to 0.95 instead of 0-1. So with a spotless reputation, your per turn goods will be multiplied by 0.95 if they pay for instant goods.
 
Originally posted by Akka
Darn, I answered on the other thread while this would have been much better to put my post here.
Akka, I answered your post in the other thread, found here . This thread was meant for a suggestion that we can realistically hope will be implemented in a patch. Your idea (which I support in the other thread) is something we can hope for in civ4.
 
Originally posted by Pembroke
Now copy&paste the above and compile the patch. :)
Good code example Pembroke. It looks right. The only problem is the reputation modifier. Every civ must have one such modifier for every other civ (just as every civ has an attitude towards every other civ), and this modifier must be changed as you do actions in the game.
Breaking an important deal where you get some instant goods and pay per turn should probably set your modifier close to 0 for the civ you screw, and a little higher for other civs. Attitude should affect this, so that a civ that likes you will trust you a bit more as well.
Breaking a deal in the 19th turn should hurt you less than breaking it in the 1st turn.

Also, honoring a deal for all 20 turns should increase your modifier slightly.

This part will probably be most work for Firaxis, but since there now probably exist a flag for each civ that tells whether they trust another civ or not, it should be doable to edit all instances in the code where this flag is modified by code that decreases the reputation modifier.

Then there must be added some code for increasing the modifier every time a per turn trade expires honorably.
 
TNO:

TOP
for i=1 to 1.000
:goodjob:
i=i+1
return TOP
END



:lol: Jeez, that was so long ago i almost couldn't remember the 'go back' command ;)
 
Hurricane and Killer: It's ok for me to get infinite amount of praise ;)
 
Back
Top Bottom