Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving the AI good trades is stored as credit #11326

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

tuvus
Copy link
Collaborator

@tuvus tuvus commented Mar 17, 2024

While trading with the AI, I am not always sure how much gold they want for each item. In order to trade for an item I have to give the AI more gold than it is actually worth or else the trade will take forever to get through.

This PR works on improving that by adding in "gift" relations. Anytime a civ gives the AI a good trade, the excess gold value will be stored as the "We appreciate your gifts" modifier. This gift is then used as credit for a future trade with the AI.

  • Declaring war also removes some of the credit.
  • The credit does deteriorate over time.
  • Credit determination can vary from 40 GPT to 2% of the value based on neutral relations. The relations can change this.
  • Each credit shown as "We appreciate your gifts" amounts to around 20 gold without inflation or speed modifiers.
  • The value of the credit varies based on the civ's perceived inflation which depends on their GPT.
Picture After giving Babylon some gold, they now have the credit stored and will be willing to give some of it back in trades.

GoldGifting

Also, more tests, these might be the first tests to include trading in them. I couldn't find any tests covering trades.

@yairm210
Copy link
Owner

I'm fine with gifts, but this should only be if you're giving them something for free.
The point of the "you don't know how much they want" is to make it more like human negotiation. If you offer too much, that's part of the plan!

This is also why we don't have a "what would it take" button - I am fundamentally opposed, since that allows you to game the AI to give them not one gold more than the bare minimum.

@tuvus
Copy link
Collaborator Author

tuvus commented Mar 19, 2024

The point of the "you don't know how much they want" is to make it more like human negotiation.

The problem with that is that the AI doesn't negotiate in a very human-like manner (There is almost no way that it can act human-like in all situations). The AI is never desperate and can't understand when a trade that is usually slightly bad is actually really good. I lost where the post was (maybe on Discord), but someone said along the lines of, "Why should I trade with the AI if it always gives me a bad trade?" and this is one way to counteract that.

It might be better to make it percent-based. When a trade is accepted with both sides offering something, we take only X% of the extra value of one side to store as a gift.
We could also make it moddable. The base ruleset can have this at 0% so that other mods can change it to a higher percentage to enable it.

Also, I forgot to mention, we might be able to have gifting units increase this gift value so that players can trade units for gold to the AI.

@tuvus tuvus added the AI label Apr 11, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@tuvus
Copy link
Collaborator Author

tuvus commented May 3, 2024

I'm fine with gifts, but this should only be if you're giving them something for free.

Would something like reducing the gift value by 130% of the value from the non-gift side work? This would still allow the case where you want to give a lot of money for very little in return but for the AI to still understand that it is a gift. While still allowing the for the haggling loss.

For example, a trades with b.
a has a value of 10, b has a value of 20.
b ends up gifting a with a value of 7. (20 - (10 * 1.3))

@tuvus tuvus closed this Jun 1, 2024
@tuvus tuvus deleted the AITradeRelations branch June 1, 2024 15:27
@tuvus
Copy link
Collaborator Author

tuvus commented Jun 1, 2024

Ooops, that was an accident

@SomeTroglodyte
Copy link
Collaborator

Ooops, that was an accident

Trouble with undelete branch and reopen?

@tuvus
Copy link
Collaborator Author

tuvus commented Jun 2, 2024

I am not sure how to undelete a batch-delete operation. The changes can still be seen in the files changed luckily.
I'll probably wait until I get the motivation to clean up this PR though.

@SomeTroglodyte
Copy link
Collaborator

No idea what a batch-delete is in this context. When I see "deleted the whatever branch whenever" I always also see a github offer to undelete... And I only delete local after seeing that button and seeing a fetch notices the tracked online branch is gone. 🤷

@SomeTroglodyte
Copy link
Collaborator

But come to think of it, I manage to lose (not loose) source text too from time to time- worst is when I forget a Studio bug: "Create patch" from its git log display commit list often creates patches that have the name of the selected commit, but the diff from another. And I prefer deconstructing a commit chain via "out of git" storage to complicated rebases...

@tuvus tuvus restored the AITradeRelations branch June 6, 2024 01:37
@tuvus
Copy link
Collaborator Author

tuvus commented Jun 6, 2024

Wait, no I didn't! I only deleted the remote branch!

@tuvus tuvus reopened this Jun 6, 2024
# Conflicts:
#	core/src/com/unciv/logic/trade/TradeLogic.kt
Copy link

github-actions bot commented Jun 6, 2024

Conflicts have been resolved.

@github-actions github-actions bot removed the Conflicts label Jun 6, 2024
@tuvus
Copy link
Collaborator Author

tuvus commented Jun 6, 2024

Alrighty, so there are two ways to preserve haggling and also allow for gifts in the same trade.

  1. After a certain percentage of the original amount, the rest of the value of the trade will go to gifts. Ex: They have 100 gold of offers and we have 300 gold of offers. If the arbitrary percentage is 200%, 300 - 100 = 100 gold will count as gifts.
  2. A certain percentage of extra gold is given as gifts. Ex: They have 100 gold of offers and we have 300 gold of offers. If the arbitrary percentage is 70%, 300 - 100 = 200 then we multiply the percentage: 200 * 70% = 140 gold that will count as gifts.
  3. Implement both of these and make them moddable. Then decide on values that we want.

Note that gold gifts do deteriorate over time.

@yairm210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants