Making new "tradeable" categories

this might be too complicated for the AI. don't think the AI will make good deals. but the idea is great.
 
this might be too complicated for the AI. don't think the AI will make good deals. but the idea is great.
The AI deal making is determined by coding. Basically, it makes an overall trade value based on what you're giving them compared to what they are giving you in return. If the AI makes a bad trade, it's only because the coding used to determine trade value was not very good.

For example, this is the code used to determine the value of traidng a tech:
Spoiler :
Code:
int CvTeamAI::AI_techTradeVal(TechTypes eTech, TeamTypes eTeam) const
{
	FAssert(eTeam != getID());
	int iKnownCount;
	int iPossibleKnownCount;
	int iCost;
	int iValue;
	int iI;

	iCost = std::max(0, (getResearchCost(eTech) - getResearchProgress(eTech)));

	iValue = ((iCost * 3) / 2);

	iKnownCount = 0;
	iPossibleKnownCount = 0;

	for (iI = 0; iI < MAX_CIV_TEAMS; iI++)
	{
		if (GET_TEAM((TeamTypes)iI).isAlive())
		{
			if (iI != getID())
			{
				if (isHasMet((TeamTypes)iI))
				{
					if (GET_TEAM((TeamTypes)iI).isHasTech(eTech))
					{
						iKnownCount++;
					}

					iPossibleKnownCount++;
				}
			}
		}
	}

	iValue += (((iCost / 2) * (iPossibleKnownCount - iKnownCount)) / iPossibleKnownCount);

	iValue *= std::max(0, (GC.getTechInfo(eTech).getAITradeModifier() + 100));
	iValue /= 100;

	iValue -= (iValue % GC.getDefineINT("DIPLOMACY_VALUE_REMAINDER"));

	if (isHuman())
	{
		return std::max(iValue, GC.getDefineINT("DIPLOMACY_VALUE_REMAINDER"));
	}
	else
	{
		return iValue;
	}
}

This will eventually be one of the areas that will require some testing to see what values should be incorporated into determining a unique building's worth.

JD
 
This is awesome stuff.... could this be extended to trading contact with other civs, like in Civ3?

For example, I am England and I have met France. However, I meet Germany and Germany has no contact with France. In Civ3 you could trade contact between civs like this.

Cheers,
ripple01
 
Okay, so here is a "beta" of my tradeable unique buildings MOD. I am not including the open source yet (as I just want some of you to test it). The ONLY thing it adds to the game is the ability to trade unique buildings after you research CONSTRUCTION. (I use the word "only" lightly... there were WAY more things to change/add than I thought there would be just to make this possible...) Within the XML files, searching "JDHalfrack" will show you what I added to make the tech requirement for enabling tradeable unique buildings.

Things that still need work:

Unique building values: Right now, the "value" for trading a unique building is equal to the production cost of the building times 37.
Code:
iCost = std::max(0, GC.getBuildingInfo(eUniqueBuilding).getProductionCost());
iValue = (iCost * 37);
We need to find a better value for this. I think it should basically incorporate building specifics like happiness bonuses, health bonuses, production increaes, etc.... So, at some point, I will work on this.

Denying unique building trading: When a team doesn't want to trade a technology, it shows up, but it's red. Usually it says stuff like "We would never trade to you, our worst enemy" or "We aren't ready to start trading this just yet" or something like that. Currently, AI teams will never make a trade impossible. It may still deny a trade because the value isn't good enough, but it won't initially deny a trade.

Overwriting other unique buildings: The way the unique buildings work is based off of "BuildingClassTypes." For example, the Ziggurat replaces the Courthouse because they are both from the same BuildingClassType. So, be aware that if you trade for a unique that is the same BuildingClassType as YOUR unique building, it will be over written. When I first started making this MOD, it was for a bigger MOD I have been working on where each civilization has a unique building that is not based on any other civilization's base BuildingClassType. So, it's not a big deal for me, but it may be an issue for some of you.

Besides that, it's pretty much good to go. Try it out and let me know what you think.

JD
 

Attachments

I think, you will first get Rathaus for Courthouse and then Sacrificial Altar for Rathaus?!
 
If Holy Rome trades you the Rauthaus first, you will lose the ability to build a courthouse, but have a Rauthaus. So, that's a trade up. But then, if the Aztecs trade you the Sacrificial Alter, you will lose the Rauthaus, but gain the Sacrificial Alter. So, that's a toss up based on what you are looking for in a building.

There's no way around this the way the buildings are set up.

JD
 
I would make the value be a difference function, since they are losing access to one building, gaining access to another. If I trade you an enhanced Courthouse which grants 1 extra :culture:, but costs 50 :hammers: more than a basic courthouse, and in return I get a unique market that adds 3 extra :gold: for a mere 10 :hammers: more, then I came out in the lead. Even though your net extra hammer cost is higher, AND your base Hammer cost (current formula) is much higher, the overall gain for my side was the greatest. This will naturally extend itself to cases like the Rathaus vs Altar discussion where the AI will consider the current best build for their tastes (if you utilize the Emphasis information and other such tie-ins when weighting the buildings)

Possibly a quick loop over all existing cities to check the AI_buildingValueThreshold function would suffice. Though that wouldn't allow for planning ahead to future cities, it would provide a reasonable metric.
 
:culture:
I would make the value be a difference function...
Yeah, this is my thought to. The question is what to use as "modifiers." For example, what should be the value of gaining/losing 1 :culture: or gaining/losing 3 :gold:. Also, what actual building values should be included? For example: difference in air lift capability? I mean currently, there are no unique buildings that allow air lift capabilities anyway, but someone could make one.

Actually, should the values be edittable within an XML file? If so, where? LeaderheadInfo? Basically, one leader may value culture more than gold or air lift capibility (I doubt it... :crazyeye:).

Just throwing ideas out. I'm not even sure people will like this MOD...

JD
 
Existing courthouses are automatically traded up to whatever you have available now?
The BuildingClassType: BUILDINGCLASS_COURTHOUSE contains the Courthouse and all the unique buildings that replace the courthouse. You may only have one building from any BuildingClass at any given time. So, the last trade you make involving buildings in the BUILDINGCLASS_COURTHOUSE BuildingClassType will be the only building from the BUILDINGCLASS_COURTHOUSE BuildingClassType you may build.

Make sense?

JD
 
Existing courthouses are automatically traded up to whatever you have available now?

So, the last trade you make involving buildings in the BUILDINGCLASS_COURTHOUSE BuildingClassType will be the only building from the BUILDINGCLASS_COURTHOUSE BuildingClassType you may build.

That covers future courthouse builds. I believe (and want to know) that MqsTout was asking about courthouses you've already built? Do they become the new type of courthouse in your cities just like when you capture a city with UBs?
 
That covers future courthouse builds. I believe (and want to know) that MqsTout was asking about courthouses you've already built? Do they become the new type of courthouse in your cities just like when you capture a city with UBs?

I'm assuming the do, in the same way that conquered cities have your UB.
 
Unless specifically coded (by JDHalftrack) to cycle your cities and change buildings, it would not. I would say it is worth a global variable (boolean) to control having it happen or not on a mod-by-mod basis
I actually do have it cycling through each city and replacing the old buildings with the new ones (assuming you have one built). However, I agree, maybe you should be able to determine whether or not it would with a boolean. I would have to figure out how to make it overwrite the old default buildings upon completion of the new unique building (which shouldn't be hard). I'll look into it. Right now, I'm just trying to guage how much interest this type of MOD has, and whether or not the concept works.

Which reminds me: Thanks for all the feedback and questions!

JD
 
Honestly, I'm not at all interested in swapping UB/UU, but I am generally interested in other trade options as long as the AI can use it okay, such as the things Civ3 had (contacts, units (only those in borders already, such that you can actually get diplomacy out of giving units), maybe war ultimatums...)
 
I'm curious how you made the UB part work. Did you change the UB for the civilization? Depending on how you did it, it could be possible to allow the player to build any type of the ones they have available. You'd need to ensure they don't build 2 of the same class, but that's not hard.
 
Back
Top Bottom