Old Wonders - New Abilities

Which is one reason I always convert Civ Python code no matter where I get it from ;)

I'm not just porting blindly -- I am reading through the code to understand what it supposed to be going on. I have gotten a lot of mileage out of CyInterface.addmessage to tell me WHAT is going on so I can figure out the WHY.

My first conversion was Via Appia/Golden Spike, although I modified it slightly to improve existing routes instead of creating new ones. Still, when other people thought they were too powerful, I created the new code that creates a Paved Roads network for the Via and a true Transcontinental Railroad for the Spike.
 
If I can ask -- what is the difference between contact with a player and contact with a team? I know nothing about multiplayer. If contacting a team means contacting every player on that team, that should help speed up Ishtar Gate and the modified Marco Polo's Embassy, shouldn't it?
 
This is tsentom1's original code
Code:
## Ishtar Start ##

		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_ISHTAR' ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iTeam = pPlayer.getTeam()
			pTeam = gc.getTeam(iTeam)

			for iPlayer in range(gc.getMAX_PLAYERS()):
				ppPlayer = gc.getPlayer(iPlayer)
				if (ppPlayer.isAlive()):
					pTID2 = ppPlayer.getTeam()
					if iTeam != pTID2:
						pTeam.meet(ppPlayer.getTeam(), True)

## Ishtar End ##

This is what I modified into:
Code:
## Marco Polo's Embassy Start ##
		if iBuildingType == gc.getInfoTypeForString("BUILDING_MARCO_POLO_EMBASSY"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			iTeam = pPlayer.getTeam()
			for iTeamX in xrange(gc.getMAX_CIV_TEAMS()):
				pTeamX = gc.getTeam(iTeamX)
				if pTeamX.isAlive() and iTeamX != iTeam:
					pTeamX.meet(iTeam, true)
## Marco Polo's Embassy End ##

1) Why is there a need to get the plot of the city to get the owner of the plot when you can get the owner of the city directly
2) Usage of gc.getMAX_PLAYERS without the CIV will loop through even barbarians, what for?
Not sure about minor civs since there isn't any in BTS
3) Why bother to loop through players when you can loop through teams directly?
4) Usage of xrange instead of range
5) I don't even see a need to define pTeam
6) Team is obviously more efficient than Player. In a game with 2 teams, but each team has 10 players, my "meet team" codes are only going to activate 2 times, his is going to activate 20 times

This is just one of those with minor improvements, since this is a simple wonder.
But even for a simple wonder like this, I make sure there ARE improvements, or I might as well just post a link to the old download link directly...

Contacting a team does contact all players in the team directly.
 
This is tsentom1's original code
Code:
## Ishtar Start ##

		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_ISHTAR' ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iTeam = pPlayer.getTeam()
			pTeam = gc.getTeam(iTeam)

			for iPlayer in range(gc.getMAX_PLAYERS()):
				ppPlayer = gc.getPlayer(iPlayer)
				if (ppPlayer.isAlive()):
					pTID2 = ppPlayer.getTeam()
					if iTeam != pTID2:
						pTeam.meet(ppPlayer.getTeam(), True)

## Ishtar End ##

This is what I modified into:
Code:
## Marco Polo's Embassy Start ##
		if iBuildingType == gc.getInfoTypeForString("BUILDING_MARCO_POLO_EMBASSY"):
			pPlayer = gc.getPlayer(pCity.getOwner())
			iTeam = pPlayer.getTeam()
			for iTeamX in xrange(gc.getMAX_CIV_TEAMS()):
				pTeamX = gc.getTeam(iTeamX)
				if pTeamX.isAlive() and iTeamX != iTeam:
					pTeamX.meet(iTeam, true)
## Marco Polo's Embassy End ##

1) Why is there a need to get the plot of the city to get the owner of the plot when you can get the owner of the city directly
2) Usage of gc.getMAX_PLAYERS without the CIV will loop through even barbarians, what for?
Not sure about minor civs since there isn't any in BTS
3) Why bother to loop through players when you can loop through teams directly?
4) Usage of xrange instead of range
5) I don't even see a need to define pTeam
6) Team is obviously more efficient than Player. In a game with 2 teams, but each team has 10 players, my "meet team" codes are only going to activate 2 times, his is going to activate 20 times

This is just one of those with minor improvements, since this is a simple wonder.
But even for a simple wonder like this, I make sure there ARE improvements, or I might as well just post a link to the old download link directly...

Contacting a team does contact all players in the team directly.

Thank you! This does look more efficient, and thank you for the explanation. This is why I always try to post anything I want to do before I add it to the mod, so that I can get some feedback. Other people will suggest things that I had not even considered.

Actually, we do have minor civilizations in C2C. Would that have an effect at all? Minor civilizations can be contacted, but can't conduct diplomacy and are at war with everyone else (full civ or minor).
 
Well, I only bother to test things I am interested in :D
Since there are no minor civs in BTS, I never bother to find out whether they are affected.

Anyway, it shouldn't be difficult to find out.
Just remove the tech requirement and set cost to 1.
Start a game where there are normal civs, and minor civs.
Build it and you get your answer :D
If they are excluded and you want them to be included, then just use the same code without the CIV like what tsentom1 used
 
Personally, I don't think it is a good idea to add python wonders to C2C.
It is obvious that AI is somewhat lacking in abilities to cope with all the special components of C2C already.
You see all those threads about easy games, insane gold, overwhelming happiness/health etc.
All those newly added components and even old game options like commanders pretty much already make AI handicapped.
Addition of more python wonders is simply going to kill the AI off, since like what Dancing said, they have absolutely no idea what they are building.
You can make use of Flavour tags, AI Weight or even AI_chooseProduction to dupe them to build the wonders, but all they will know is this wonder is good for military, because it has a military flavour tag. Why is it good for military, no idea.
But humans, who can read the descriptions, will know where and when is good to build the wonder.
 
Personally, I don't think it is a good idea to add python wonders to C2C.
It is obvious that AI is somewhat lacking in abilities to cope with all the special components of C2C already.
You see all those threads about easy games, insane gold, overwhelming happiness/health etc.
All those newly added components and even old game options like commanders pretty much already make AI handicapped.
Addition of more python wonders is simply going to kill the AI off, since like what Dancing said, they have absolutely no idea what they are building.
You can make use of Flavour tags, AI Weight or even AI_chooseProduction to dupe them to build the wonders, but all they will know is this wonder is good for military, because it has a military flavour tag. Why is it good for military, no idea.
But humans, who can read the descriptions, will know where and when is good to build the wonder.

This is true. Ideally use regular tags (and ask for more if you have to) for the functional effect, and Python as needed for 'decorative effects' (things that are neither here nor there to the AI). Obviously there are some things that is simply impossible for (via Apia and Spike are good examples) - ideally those aspects would be more 'flavor' than substance, but at least try to keep their prevalence down.

Note - we can also consider adding more 'hint' tags for the AI - so tags that tell it what aspects of its situation is likely to be improved even if they cannot explain exactly what is being done (effectively extended flavor tags).
 
Personally, I don't think it is a good idea to add python wonders to C2C.
It is obvious that AI is somewhat lacking in abilities to cope with all the special components of C2C already.
You see all those threads about easy games, insane gold, overwhelming happiness/health etc.
All those newly added components and even old game options like commanders pretty much already make AI handicapped.
Addition of more python wonders is simply going to kill the AI off, since like what Dancing said, they have absolutely no idea what they are building.
You can make use of Flavour tags, AI Weight or even AI_chooseProduction to dupe them to build the wonders, but all they will know is this wonder is good for military, because it has a military flavour tag. Why is it good for military, no idea.
But humans, who can read the descriptions, will know where and when is good to build the wonder.

I understand what you are saying. I think there are two other things to consider:

AI's always like to build Wonders. I created my own versions of Cahokia Mounds and Serpent Mounds a while back (Cahokia Mound gives +4 culture from Tumulus and Serpent Mound gives +2 science from Tumulus). When I added them to my current game, I was already past building them, since I made them go obsolete at Theology. The AI's snapped them up in a turn.

If the Wonder effects are made global, then it doesn't matter which city builds the wonder, and the AI will get the effect regardless of where it is built. These are the Python things that I have done.
  • Alamo: When a unit is killed, grants a flat culture bonus to all cities.
  • Blarney Castle: Uses a Python callback to trigger an event every 50 turns.
  • Field of the Cloth of Gold: +3 relations with all leaders on building
  • Golden Spike: Builds a railroad to the west and eastmost points on the continent. It does sort of matter which city builds the Spike, for maximum length of railroad, but for a given continent, the west and east endpoints are fixed.
  • Via Appia: Connects all cities on the same continent

Somewhere down the line, I would like to have more XML tags implemented so the AI can properly evaluate the Wonders.
 
You mentioned about the 2 mounds, but they are not in your python wonder list.
Thus, the AI built them because they do know what they are about.

I tried before for my own works by giving them high flavour value like 10.
Since my works usually contain simply just GP points and culture output, the AI is simply evaluating based on just these and the cost.
With the flavour tag, the AI does build them if I don't, but they don't really "snatch" them.
When I set the cost to simply 1 hammer, they still take few turns before they decide to build, even when they have 5 or 6 cities. They think building warriors or granaries are actually more important than a 1 hammer world wonder -.-
Thus, unless you gave your python wonders very high XML effects such that AI are building them for the XML effects, chances are humans are the ones who will build them first if they think it is worth it.

Anyway, using your alamo as an example, how will you induce the AI to build in the right situation?
Give a cultural flavour tag?
If I really want culture wonders, I will choose real culture generation ones like Sistine Chapel in BTS
With a cultural flavour tag, AI may think this is also a culture generation wonder, but if it does not go to war, actually it does nothing helpful to the AI in terms of culture.

Field of Cloth is another example.
In a duel game where there are just you and me, will you bother to waste hammers building this?
Definitely not, but the poor AI will still be duped to build it and realise, what a waste of time :D
 
For most of these, I would think you could create a "dummy" wonder that the AI would perceive, which would at least approximate the real effects. Machu Picchu's AI evaluation would be based on the number of peaks in the city radius, for example.
 
You mentioned about the 2 mounds, but they are not in your python wonder list.
Thus, the AI built them because they do know what they are about.

I tried before for my own works by giving them high flavour value like 10.
Since my works usually contain simply just GP points and culture output, the AI is simply evaluating based on just these and the cost.
With the flavour tag, the AI does build them if I don't, but they don't really "snatch" them.
When I set the cost to simply 1 hammer, they still take few turns before they decide to build, even when they have 5 or 6 cities. They think building warriors or granaries are actually more important than a 1 hammer world wonder -.-
Thus, unless you gave your python wonders very high XML effects such that AI are building them for the XML effects, chances are humans are the ones who will build them first if they think it is worth it.

Anyway, using your alamo as an example, how will you induce the AI to build in the right situation?
Give a cultural flavour tag?
If I really want culture wonders, I will choose real culture generation ones like Sistine Chapel in BTS
With a cultural flavour tag, AI may think this is also a culture generation wonder, but if it does not go to war, actually it does nothing helpful to the AI in terms of culture.

I'm more concerned with getting an appropriate effect on the wonder. I haven't yet tried to work with the flavor tags at all, but I think putting a military flavor tag on it will work. I have the Alamo set to ADVISOR_CULTURE.

Field of Cloth is another example.
In a duel game where there are just you and me, will you bother to waste hammers building this?
Definitely not, but the poor AI will still be duped to build it and realise, what a waste of time :D

I am thinking that <iGlobalRelationsChange> is a good XML tag to have, because then the AI can evaluate it properly. I think someone else imported Taipei 101 with the same effect. If we had this tag, then the entire Python routine could be simply replaced by:

Code:
<iGlobalRelationsChange>3</iGlobalRelationsChange>

Then an AI routine could judge if it was worth building based on its current relations with other leaders. Maybe we need ADVISOR_DIPLOMACY for the diplomatic wonders (Apostolic Palace, United Nations, and maybe some others -- I have a Congress of Vienna that acts like a religion-free Apostolic Palace, but I don't quite know how to implement it myself.) This would also work for certain events; one of the original inspirations for Field of the Cloth of Gold was the +3 relations with all leaders as a choice for finishing the Best Defense quest.
 
@Alamo
How does it help in terms of military?
Military wonders would be more of those that give free promotions, cheaper units, more experience, more great generals.
A wonder that is only helpful the more units I lost doesn't sound military at all.
Unless you are thinking of sending 100 warriors out to suicide just to increase culture of all cities so that cultural defense will be higher?

@Global Relations
At the end of the day, the solution to python wonders to make AI understand is add more XML tags.
However, when you do that, they are no longer python wonders.
The problem here is that AI does not understand python, which is what you are introducing to C2C now.
By introducing more XML tags and converting python wonders to XML wonders, you are simply introducing XML wonders to C2C, whereas what you are trying to do now is introduce python wonders to C2C.

Like I said, the main problem with python wonders is that AI has no idea when is exactly a good time to build or not to build at all.
It gives the humans an advantage over the AI, which is pretty crippled in C2C already.
Even for Marco Polo's Embassy, if I already met all civs, will I bother to waste hammers on it?
Or for Alamo, if I am so advanced I am using tanks while my neighbours are still using longbowmen, what is the point of building when chances of my units dying is negligible?
Or for Via Appia and Spike, if I am playing archipaelogo maps where each "continent" has less than 5 cities, is there a point of building?
 
@Global Relations
At the end of the day, the solution to python wonders to make AI understand is add more XML tags.
However, when you do that, they are no longer python wonders.
The problem here is that AI does not understand python, which is what you are introducing to C2C now.
By introducing more XML tags and converting python wonders to XML wonders, you are simply introducing XML wonders to C2C, whereas what you are trying to do now is introduce python wonders to C2C.

The Wonders don't have to be Python. What I'm really trying to do is introduce effects that either more closely parallel the real-world effects of the Wonder, or simply generate truly unique effects. I'd prefer XML if it's possible, and Python is simply a backup if the XML is not there. I'd be quite happy if all my Wonders were done in XML, but some things will be out of XML capability. I've done a couple effects with just XML to trigger Events.

Like I said, the main problem with python wonders is that AI has no idea when is exactly a good time to build or not to build at all.
It gives the humans an advantage over the AI, which is pretty crippled in C2C already.
Even for Marco Polo's Embassy, if I already met all civs, will I bother to waste hammers on it?
Or for Alamo, if I am so advanced I am using tanks while my neighbours are still using longbowmen, what is the point of building when chances of my units dying is negligible?
Or for Via Appia and Spike, if I am playing archipaelogo maps where each "continent" has less than 5 cities, is there a point of building?

Marco Polo's Embassy: There are two other effects: +1 trade route and +1 commerce from all Merchants. So it does pay off even if you have met everyone.

Alamo: If you're that far ahead, the only reason for building it would be your score.

Via Appia and Golden Spike: On archipelago maps, they aren't that useful. Neither are Notre Dame or Three Gorges Dam. Some effects are going to be not as good on particular maps. Colossus and Great Lighthouse aren't very effective on maps with very little water. There are always corner case situations.
 
So the conclusion is that you have to add all these XML effects like commerce and trade routes, so that if the poor AI build it in a stupid situation, at least not too bad?
It is true that for XML wonders, there are also situations where building them is a bad idea.
The difference is, AI is not stupid enough to build them in "bad" situations, whereas they may build python ones in bad situations.
Have you ever seen AI build Three Gorges Dam in a one tile island?
Now is it possible that AI may build Via Appia in a one tile island?

As for Alamo, if I simply want Score, I believe there are better wonders to build.
There is this economics term called Opportunity Cost.
For the same time and effort spent on building a useless wonder, I could have spent the same effort building a better wonder, or simply more units etc
Humans understand when is a good time and place to build, AI don't

Although python can bring more flavour to the mod, bringing in new benefits that are not achievable with XML, it does make the AI more stupid.
 
So the conclusion is that you have to add all these XML effects like commerce and trade routes, so that if the poor AI build it in a stupid situation, at least not too bad?
It is true that for XML wonders, there are also situations where building them is a bad idea.
The difference is, AI is not stupid enough to build them in "bad" situations, whereas they may build python ones in bad situations.
Have you ever seen AI build Three Gorges Dam in a one tile island?
Now is it possible that AI may build Via Appia in a one tile island?

As for Alamo, if I simply want Score, I believe there are better wonders to build.
There is this economics term called Opportunity Cost.
For the same time and effort spent on building a useless wonder, I could have spent the same effort building a better wonder, or simply more units etc
Humans understand when is a good time and place to build, AI don't

Although python can bring more flavour to the mod, bringing in new benefits that are not achievable with XML, it does make the AI more stupid.

I didn't want to completely trample the previous version of Marco Polo's Embassy, and the original merchant commerce bonus is from that. It originally had +3 trade routes, but I thought lowering it to +1 would balance out.

I guess that proper AI weighting is something I still have to learn. That's a project for later.
 
@Platyping:

We have an SDK setup, the Expression System, that allows us to do many things in the XML that were previously only possible with special tags or Python. Currently it is only used for unit and building prereqs, but it can easily be extended to any unit or building tag. There is more documentation on the Expression System in the modders documentation thread. The good thing about this is that 1) it runs faster than a similar Python script and 2) the AI can understand it. Once it is fully implemented it will allow for many very unique options for XML modders.
 
I'm going to give the Alamo another small bonus. I think +25% Great General emergence within cultural borders will give it the right feel. I thought it felt incomplete when I originally posted it, and this will give the AI an XML reason to build it if it thinks it is facing a defensive war. I may up the bonus to +50%, but I think we should try it out at +25%.
 
Here are two more ideas I'm considering. I'm away from my modding computer right now, so no illustrations just yet. I will have them soon.

Maginot Line

This was one of my early Wonders. I created it back in February with the simple effect of providing a free Barricades in every city on the same continent. I would like to add, per Koshling's suggestion, a Python routine to add Bunkers along the frontier, like this:
  • Identify every square that is adjacent to a land square that you do not own.
  • If there aren't any Bunkers in adjacent squares that you own, place a Bunker in that square.
  • This will generate a line of Bunkers in every other square along your frontiers.

Keeping the Barricades will provide the proper defensive mindset of the Wonder, but they don't last long -- Maginot Line requires Trench Warfare to build and goes obsolete at Mechanized Warfare. The Bunkers will stay until the end of the game or are replaced.

Space Elevator

It occurred to me that since we pushed the spaceship parts to the Galactic Era, the Space Elevator will not do very much once it is built (since its only real ability is +25% spaceship production). I was thinking that it should also help build orbital buildings. I would like to have the Space Elevator give +50% to construction speed of the following in all cities:
  • Communication Satellites
  • Military Satellites
  • Orbital Factory
  • Solar Power Satellite
  • Zero-G Sports Arena

This can be done purely in XML. Is this a good idea? Should any other buildings be affected? I don't think we can adjust speed of Projects.
 
Here are two more ideas I'm considering. I'm away from my modding computer right now, so no illustrations just yet. I will have them soon.

Maginot Line

This was one of my early Wonders. I created it back in February with the simple effect of providing a free Barricades in every city on the same continent. I would like to add, per Koshling's suggestion, a Python routine to add Bunkers along the frontier, like this:
  • Identify every square that is adjacent to a land square that you do not own.
  • If there aren't any Bunkers in adjacent squares that you own, place a Bunker in that square.
  • This will generate a line of Bunkers in every other square along your frontiers.

Keeping the Barricades will provide the proper defensive mindset of the Wonder, but they don't last long -- Maginot Line requires Trench Warfare to build and goes obsolete at Mechanized Warfare. The Bunkers will stay until the end of the game or are replaced.

This will work if you put a unit in them as well otherwise it will just be an invite for those attacking you to take over your territory. Like forts bunkers belong to the first to put a unit in them. They also spread cultural territory.
 
Back
Top Bottom