They don't want your open borders if you're Popular+ against them in CV progress.
STEP 4: Last Few Copies Bonus
Tally up the amount the AI has of this resource, INCLUDING imports and SUBTRACTING exports (this can be higher than the amount listed in the trade screen).
- If after the trade the AI would have none of this resource left, return IMPOSSIBLE!
- If after the trade the AI would have 1 or 2 of this resource left, multiply value by 10.
This and the Diminishing Returns from the buying part should be considering each resource and valuing each instead of the whole deal at once. And instead of checking existing deals for diminishing returns, they should check (current amount they have - amount they're using),
INCLUDING imports and SUBTRACTING exports. If this number is too high just return 0 for any excess strategic resource.
Example: buyer AI has 2 excess iron. They should buy 1 iron for 70, 2 iron for 130, 3+ iron also for 130 since they don't need more than 4 excess.
(Buying Luxuries) STEP 7: Comparative Resource Happiness
- Count the amount of Happiness each player is gaining from resources.
- If seller has more resource happiness than AI (or an equal amount), multiply value by 11 and divide by 10.
- If AI has more resource happiness than seller, multiply value by 10 and divide by 11.
I don't think this part is needed. Happiness is not a competition.
Instead check AI's happiness only and value the luxury much cheaper (down to something like 5% or even 0) if AI doesn't need the happiness from the luxury, and the luxury isn't needed for CS quest or WLTKD. Getting a luxury for free isn't always a good thing, as it may shift CS quest/WLTKD requirements to something harder to obtain.
Netherlands:
I think we should simplify the checks.
Buying strategic resource: Value the exact copy of a resource higher if buying it would have given them a monopoly. All other copies don't need to be checked.
Buying luxury resource: Value a luxury resource higher if
1. they haven't already imported the resource from a major civ (should be worth at least 3

+ 3

per turn), or
2. importing this copy of resource gives them a monopoly. This check should only be done to a pure tile yield monopoly if
2a. They have a copy of this resource within working distance, or
2b. They have the Corporation tech, haven't founded a corporation, AND (the score of this corporation is higher than the current planned one OR they don't have access to any corporation)
Selling luxury resource: Value a luxury resource higher if they haven't already exported the resource to a major civ.
On actual deal value:
AI vs human: AI should always offer the lowest value when selling and highest value when buying.
AI vs AI: They should accept the deal at the average of selling and buying price, giving both parties an equal diplomatic opinion bonus.
Of course, this could already be how it works right now...