tuning economics and buildings

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
This thread is for discussion about how to tune the economics and buildings so that it is interesting, and the AI can use them to expand as well as the human player.
 
Here is unofficial patch 1.2.2. The main point is to incorporate a lot of economics feedback from Ahriman. You can install this over 1.2, or over 1.2.1; it includes all the changed files above 1.2. See this post for the contents of 1.2.1. I cannot run 1.1.x anymore since I have updated to the BTS 3.19 patch; so I cannot put these changes into a patch like 1.1.5.

* AI civs now found their spice corporation as soon as it is possible. Using a high iAIWeight did not help; so I added python for AI_chooseProduction to force it. In a few games, the AI founded its corporation as early as turn 30.

* Reduced commerce available from spice from +5 per tile to +3. There is still some underlying problem why the AI's do not expand very fast. Making this reduction does not seem to change their expansion rate; therefore, there is some other reason they do not expand. However Ahriman's feedback is that the human player expands too fast at the +5 rate.

* Fixed bug, sandstorms can no longer capture cities.

* Reduced commerce of village, town etc by -1 each, back to vanilla levels.

* Replaced harvester mechanical unit with basic desert worker. This unit made a brief appearance in 1.1.1 as the "spice collector". In addition he can now cross desert terrain just like the settler, soldier and scout. The hope was that this would make the AI more likely to found cities, but it did not help.

* Drip farm can be built anywhere there is fresh water and some food (like vanilla farm), and no longer spreads fresh water.

* Soil enricher can now only be built on bonuses.

* Mines can now be built on any hill and give +1 hammer.

* Several corporations besides the spice corporations used spice as their inputs; removed spice so these corps no longer get huge bonuses.

* Added one more hint, about spice disappearance.

* Fixed some spelling errors in the TXT_KEY strings. Now you should get "stub text" for all text in the game instead of an occasional "TXT_KEY". Of course having real text instead of stub text would be nicer. Anybody want to volunteer? Enter text into assets/xml/text/DuneWarsText.txt and send it to me.

* Graphics: Crisper images for Rabban, Baron Harkonnan and Paul; revised main menu screen.

You can get it from here:

http://jendaveallen.com/fury-road/dune-wars-patch-1-2-2.zip (5 MB)
 
I do not understand why the AI fails to expand much using the current economics system. Ahriman has pointed this out also. It is not hard for the human player to get 7-8 good sized cities by turn 250, but the AI only seems to get 2-3 cities. The cities grow fine and have a decent population; it just doesn't show much interest in building settlers. In other archipelago mapscript games, the AI builds settlers and sends them by galley. I know the AI understands that settlers can travel on "coast", because in some autoplays the AI starts a city at some distance from its current one.

Can anybody suggest how to make the AI expand better for this mod?
 
As stated elsewhere, my biggest guess is because:
a) the civ AI has always kinda sucked on water based maps
b) the AI is crippled by an inability to build farms, that increase food supply.
c) the AI doesnt' realize that hills are really good food sources (through windtraps) and so fails to choose city sites appropriately.

My point about the +3 vs +5 rate was about the rate of economy growth, rather than city expansion, though obviously these are somewhat linked; bigger economy means you can afford more city upkeep.

The roots were slightly separate; the AI cities aren't growing enough in population and it isn't founding enough new cities, and it was slow to build a spice corp and deep harvesters and get them building refineries; also possibly related to an issue where automated deep harvesters in land-locked cities don't always respond to go and build refineries on new blows, so AI had fewer spice resources than the player.

Again a linkage though, because more cities means more cultural territory means more spice blows means more spice resource means more money.
I still think you might need to spread the spice corp wealth around somehow too, but this reduction is a good idea.

Will try out this patch (though DOW2 beta for big redesign also just came out.....), hopefully should address some issues.
 
I did try the experiment to spread out corp wealth and it did not work. Perhaps I did not study it carefully enough. I did the following using WB. Create two cities, put spice corp and bank in one city, put two spice bonuses and harvesters within each city cultural border. Look at corp commerce income. Put spice corp in second city. Look at corp commerce income again. If the second corp was going to distribute the wealth, then the total corp commerce should decrease, because the second city does not have a bank. I did not see any change. Therefore, I do not think there is any way to avoid the multiplying effect of banks and civics on the corp income.

I am not sure why the AI is not founding more colonies. But, I don't think it is because of low population. In the autoplays I did, the AI's were always able to get their cities up to 12-15 population by turn 250, which is about as well as I could do. Somehow, they are just not interested in sending out settlers. I also autoplayed vanilla on an archipelago map, and the AI does send out more settlers. My guess is that something about the DW resource distribution makes the AI look around, fail to see any interesting colony sites, and decide not to build settlers.

We looked into this problem a little bit before, and determined that there is a threshold hard-coded into the AI which sets a lower limit on the usefulness of a potential colony site. With the default setting it was rejecting basically all sites as not being useful. Koma13 had a patch before, which allowed setting this threshold via xml, so we could lower it. At that time (version 1.0) it seemed that lowering this threshold made the AI more interested in founding colonies. But that was on a different mapscript, and koma13 has stated that with the current mapscript, this threshold doesn't seem to matter.

So, we need "conclusive evidence" on why settlers are less frequent than vanilla archipelago. I don't think it is population, but I don't know what it is.
 
My guess is that something about the DW resource distribution makes the AI look around, fail to see any interesting colony sites, and decide not to build settlers.

I often notice that ai builds a settler but then keep it inside city. I know that ai won't send settlers out if it doesn't has an adequate military unit to protect it. Maybe too much danger in desert? Or it's the ai_foundvalue again.
I can create a cvgamecore.dll that creates a log file and prints out in detail which decisions ai makes regarding settlers. This should help us finding the reason why ai won't settle.
 
Several people have pointed out that there seem to be a large number of buildings available in DW 1.2, and many of them are not so useful. I compared the number and usefulness of the vanilla buildings against DW, in the first six levels of the tech tree.

Vanilla has 13 non-wonders and 13 wonders; DW has 18 non-wonders and 21 wonders. Some of the DW wonders are not really so wonderful, like nutrient convoy; it is not very expensive, a fair number of them are available, and the effect is relatively small compared to unique wonders. Still, there are significantly more in DW than vanilla. Details inside the spoiler tag.

Spoiler :

Vanilla buildings by tier:

1. barracks, monument / stonehenge
2. lighthouse, granary, monastery, walls / great lighthouse, moai statues, pyramids, great wall
3. temple
4. library, forge / collosus
5. aqueduct, harbor / parthenon, statue of zeus, shwedagan paya, hanging garden
6. colloseum, market / heroic epic, national epic, great library, mausoleum

Dune wars buildings by tier:

1. barracks, city water trap, food warehouse, monument / aql monument, reservoir
2. food slik, monastery, spice refinery / water discipline, kiswa, pillar of fire
3. food silo, defense grid, temple / art of kanly, underground routes, house shield, obelisks of Muad'Dib, oracle
4. trade port, crystal database / weld factory
5. qanat, spaceport, house library / nutrient convoy, incense convoy, great film library, shrine of the worm, hajj monument
6. market, reception hall / silk convoy, spice convoy, harg pass, temple of first moon, great memorial

Vanilla building job function:

monument: culture at colony
lighthouse: food on ocean
granary: health, growth
monastery: spread religion
walls: defense
temple: happiness, GP
library: culture, research, GP
forge: hammers, happiness, GP
aqueduct: health
harbor: health, gold
colloseum: happiness
market: gold, happiness

Dune wars building job function:

city water trap: growth
food warehouse: growth, health
monument: culture at colony
food slik: growth, health
monastery: spread religion
spice refinery: happiness, GP
food silo: growth, health
defense grid: defense
temple: happiness, GP
trade port: culture
crystal database: research
reception hall: happiness
qanat: health
spaceport: health, gold
house library: research, GP
market: gold, happiness, GP

Vanilla wonder job function:

stonehenge: free monument
great lighthouse: food on ocean
moai statues: gold
pyramids: any government civic
great wall: defence
collosus: industry on ocean
parthenon: GP rate
statue of zeus: enemy war weariness
shwedagan paya: any religion civic
hanging garden: health on continent
heroic epic: military production
national epic: GP rate
great library: research
mausoleum: extend golden age

Dune wars wonder job function:

aql monument: free monument, GP
reservoir: GP rate
water discipline: culture, GP rate
kiswa: industry on ocean
pillar of fire: gold
art of kanly: military production
underground routes: gold
house shield: defence
obelisks of Muad'Dib: any religion civic
oracle of hajra: free tech, GP
weld factory: hammers, health
nutrient convoy: health, happiness
incense convoy: health, happiness
great film library: culture, research, GP
shrine of the worm: happiness
hajj monument: any religious civic
spice convoy: happiness
silk convoy: happiness
harg pass: golden age
temple of first moon: culture, GP rate
great memorial: enemy war weariness


For regular buildings, here are some proposed changes.

* I am not sure of the reason for splitting up granary into three buildings; merge it back into one.

* The trade port and crystal database provide only small benefits. Eliminate them.

* Rename spice refinery to just plain refinery. It has nothing to do with spice; it gives an additional happiness for mineral bonuses.

For wonders, here are some proposed changes.

* The idea of getting happiness/health from off-world, with a limited number of opportunities, seems like a good one. There are four convoys; some of them provide both health and happiness. Instead each one should provide +2 health *or* +2 happiness; there should be a small world limit of 3 for each; there is no point to a national limit. We can adjust this a little if we find health or happiness restricting growth. Also using "off-world" in the name instead of "convoy" seems to fit the theme better.

* Several of the wonders provide benefits at coastal cities. This doesn't seem to fit Dune. Without studying it very hard, we could just delete reservoir, kiswa, pillar of fire, underground routes, weld factory. In the future if we change water for health, we can replace reservoir and redefine water discipline.

Any disagreements or additional suggestions?
 
* I am not sure of the reason for splitting up granary into three buildings; merge it back into one.

I agree. I always ending up building none of them. Same for trade port.

* Rename spice refinery to just plain refinery. It has nothing to do with spice; it gives an additional happiness for mineral bonuses.

This seems to be a general problem with names in dw. They don't give you what they promise (eg. desert warfare).

Several of the wonders provide benefits at coastal cities.

Remember, in dw every city is a coastal city.
 
Remember, in dw every city is a coastal city.

Really? So a wonder which gives +2 Trade Routes in every coastal city, gives +2 trade routes in every city? That affects some of the wonders. Others which give +1 hammer or +1 food in ocean tiles, still only benefit cities which are really "coastal".
 
I often notice that ai builds a settler but then keep it inside city. I know that ai won't send settlers out if it doesn't has an adequate military unit to protect it. Maybe too much danger in desert?

You sir, are a genius. Based on your suggestion I turned off the worms and storms, to make the desert safe. Now the AI happily builds 6-8 cities by turn 250. That was the problem! Interested players can try this on their own by editing assets/python/DuneWars.py. Find the function onEndGameTurn and comment out two lines:

Code:
	# Take multiple actions at the end of each player turn
	def onEndGameTurn(self, argsList):
		iGameTurn = argsList[0]
		self.Initialize()
		self.Dequeue()
		(iUnowned, iWormCount, iSpiceCount, iStormCount, \
			iMaxStr, lStorms) = self.Count()
		# self.WormAdd(iUnowned, iWormCount, iMaxStr)
		self.BlowAdd(iSpiceCount)
		# self.StormAddSubtract(iUnowned, iStormCount, lStorms)
		self.Thumper()
		self.SpiceDecay()
		self.SpiceBlow()
		self.TleilaxSpy()
		self.StatPrint(iGameTurn)

Comment out the calls to WormAdd and StormAddSubtract, and none of these units will ever be added.

Now for the real solution. I have made sandstorms strength 1000, because it would be very odd for a player unit to attack one and win. Similarly, I have made the sandworms start out at strength 20 and increase when the players have higher strength units. I will have to find another way of doing this, so that these units can have zero attack strength. I thought I had started a thread a while back about how to make units un-attackable, but I cannot find it. Offhand I am not sure how to approach this, but I will make it top priority.
 
Really? So a wonder which gives +2 Trade Routes in every coastal city, gives +2 trade routes in every city? That affects some of the wonders."

We edited isCoastal() to always return true. Else you could build domain_sea units only in some cities.

Others which give +1 hammer or +1 food in ocean tiles, still only benefit cities which are really "coastal".

Yes, I think it depends on terrain/plot typ. But you still can build it everywhere I suppose.

Now for the real solution.

There is a AI_getWaterDanger in CvPlayerAI. It calculates how dangerous a water area is (it counts all enemy units in a certain range that can attack).
We could remove all barbarian units from that danger count. This will maybe also help fixing that hover spam (only a guess).
 
There is a AI_getWaterDanger in CvPlayerAI. It calculates how dangerous a water area is (it counts all enemy units in a certain range that can attack). We could remove all barbarian units from that danger count. This will maybe also help fixing that hover spam (only a guess).

That is a good tip. It counts units with any attack strength that are not defensive only. I have made the storms and blows attack strength 0 and defensive only. Therefore only the worms are threats. This has one side effect, units can attack and kill storms. I have started up a new thread to see if there are any other possibilities.

There must be some other part of the code which decides how many sea combat units to build. Earlier, I found that hover spam was greatly reduced when I lowered the strength of the worms from 100 to 20; AI_getWaterDanger doesn't care what the strength is. So if we hack that function, I do not think it will affect hover spam.

If I cannot figure out how to make units un-attackable, there is one other approach I want to try first. But it will be a little painful. In Gods Of Old, there is a plague effect which acts similar to the way storms should act. To the game, it is just an "effect" displayed on the map. The python in Gods Of Old uses some nasty hacks to keep track of the locations of these effects. I had been hoping to use units, for which the game will naturally keep locations and allow movement, etc. But I can write some "moving effect" code in python and just kill the units that I'm going to kill, without doing real attacks.
 
* I am not sure of the reason for splitting up granary into three buildings; merge it back into one.
* The trade port and crystal database provide only small benefits. Eliminate them.
* Rename spice refinery to just plain refinery. It has nothing to do with spice; it gives an additional happiness for mineral bonuses.

Agree with all of these. I'd basically make the Refinery a Forge substitute; primary purposes is for hammer bonus, happiness or whatever is secondary. I'd consider merging this with the Weld factory.
I'd merge a lot of the trade bonus buildings, have maybe 1 per era.

But the problem doesn't stop here; in Civ, many of the buildings are available in early techs and then there are fewer new buildings in later eras, but there are still many new buildings in later eras.
Some other later buildings: cut reception hall (or merge with the theatre one). The shrine of the worm or something gives way too much happiness (like +1 per 20% science is often an easy +4 happiness).

I have made the storms and blows attack strength 0 and defensive only
Another possibility; give them a 100% withdraw chance.
Or: try implementing FFH style attack/defense values, and give them 0 attack but 1000 defense.

Congrats on pinning down the issue, that was a very good find.

Another possibility; rather than just having barbarian worm units out in the desert which might scare the AI, you could make an "on-move" event trigger similar to how Treant spawning with Fellowship of Leaves works in FFH.

Any time a unit moves into a new desert tile, there is a small chance (maybe 2%?) that a sandworm is created somewhere nearby, within a 3 tile radius.

This will slow the mod down performancewise, but hopefully not too much.

And it has the added awesomeness benefit of having worms actually attracted by vibrations of surface units!
Would be even more awesome if you could limit the unit types that triggered it, so infantry or rovers or surface vehicles did, but maybe some hover units and thoptor units did not.

Then, you get the same effect of worms in the desert popping up to potentially devour units wandering on the surface, but you don't have to have an army of barbarian worms in the desert.

And you could have any worm act like a missile unit in that it automatically suicided after combat so that the worm doesn't then hang around on the map; after eating one of your units, the worm goes back under the sand again.

And you could easily make the worms whatever strength you wanted without scaring the AI.
 
Another possibility; give them a 100% withdraw chance.

Or: try implementing FFH style attack/defense values, and give them 0 attack but 1000 defense.

Thanks for the suggestions. Withdraw chance only works when the unit attacks. It is a common misunderstanding, but if you are the defender, your withdraw chance does not matter. Splitting up attack/defense is a serious SDK mod which is beyond my ability.

Another possibility; rather than just having barbarian worm units out in the desert which might scare the AI, you could make an "on-move" event trigger similar to how Treant spawning with Fellowship of Leaves works in FFH.

Any time a unit moves into a new desert tile, there is a small chance (maybe 2%?) that a sandworm is created somewhere nearby, within a 3 tile radius.

And it has the added awesomeness benefit of having worms actually attracted by vibrations of surface units!

Would be even more awesome if you could limit the unit types that triggered it, so infantry or rovers or surface vehicles did, but maybe some hover units and thoptor units did not.

The worms are currently attracted to surface units. The highest attraction is to thumpers. I haven't yet added a capability to have some units ignored either by type, civ or promotion, but it is somewhere on the to-do list.

The reason I did not make them randomly appear is that I wanted the player to see them coming. If you have scouts out, you will get more warning of a worm coming into the area. I know if I see a storm or worm coming, it affects my plans, and that seems to be a good idea. If they randomly pop up, then it is random and I cannot plan around it.

I will try the map effect only approach, and see what happens.
 
Thanks for the suggestions. Withdraw chance only works when the unit attacks. It is a common misunderstanding, but if you are the defender, your withdraw chance does not matter

In FFH at least (maybe it there was their tweak) and in Warhammer (based on FFH codebase) there is defensive withdrawal activated on some cavalry units.
I don't know the code details though, that may have been an option they enabled.

If they randomly pop up, then it is random and I cannot plan around it.

Agreed, which is why I would have the popup 2 tiles or 3 tiles away, not on an adjacent tile (or very rarely an adjacent tile).

But as it is, with only 1 move they are incredibly easy to avoid, and never pose a threat to any non-automated units.

It seems like Worms should mostly be eating deep harvesters, but you definitely *don't* want a result that makes it so you are force to micromanage your deep harvesters in order to avoid losing them. That would get frustrating and boring fast.
 
Agreed, which is why I would have the popup 2 tiles or 3 tiles away, not on an adjacent tile (or very rarely an adjacent tile).

But as it is, with only 1 move they are incredibly easy to avoid, and never pose a threat to any non-automated units.

The effect I am aiming for, which maybe I have not achieved, is that you should see a worm coming and decide if your worker should finish that improvement, or flee for cover. The spice harvester only takes one turn to create so perhaps I did not achieve the effect. What do you think about making that take 2-3 turns to create? If you get a big spice blow near you, it will take a little more time before you can see the high income from it.

It seems like Worms should mostly be eating deep harvesters, but you definitely *don't* want a result that makes it so you are force to micromanage your deep harvesters in order to avoid losing them. That would get frustrating and boring fast.

I don't tend to pay much attention to the DH besides occasionally counting to see how many I have left. On automation they seem to do well at finding any new blow and building on it. So I don't think there is a micromanagement aspect, or at least there doesn't need to be.
 
What do you think about making that take 2-3 turns to create?

Hmm, maybe. Hopefully the micromanagement wouldn't be too much, as the automated worker would still get activated and deautomated when a barbarian unit showed up nearby. Another possibility would be to give worms 2 moves (or double moves in deep desert).

But this would still work better with worm spawning than generic barbarian worms; worms could have a much higher chance of spawning on or next to a spice tile, particularly if it have a refinery on it.
would also be cool if worms sought out refineries and auto-pillaged them when they moved onto the tile.
So I don't think there is a micromanagement aspect, or at least there doesn't need to be.

I agree that there is no micromangement aspect to them now. But, if worms sometimes ate automated harvesters, there could be incentives to micromanage if failing to do so meant that you unnecessarily lost harvesters - and we want to avoid incentives to micromanage here, since its not fun to do so.
As long as automated workers get deactivated when a worm shows up though, this shouldn't be a problem.
 
But this would still work better with worm spawning than generic barbarian worms; worms could have a much higher chance of spawning on or next to a spice tile, particularly if it have a refinery on it. It would also be cool if worms sought out refineries and auto-pillaged them when they moved onto the tile.

Let me describe the exact worm AI. It does the first available of these actions:
1. Thumper adjacent? Destroy it.
2. Unit or improvement adjacent? Destroy it.
3. Any thumper visible in 2 tile radius? Move towards it.
4. Any other unit or improvement visible in 2 tile radius? Move towards it.
5. Move in random direction

Having them all out there means the amount of worms is independent of the amount of player activity on the desert. Popping them nearby to units out there seems much more fake to me.
 
Having them all out there means the amount of worms is independent of the amount of player activity on the desert. Popping them nearby to units out there seems much more fake to me.

Maybe, but I'd ask this question; if a sandworm burrows in the desert and doesn't eat anyone, is it really there?

I would say that there are plenty of (uncountable) worms in the desert, but they only actually surface and get noticed (and become a unit that the civ engine needs to keep track of) if disturbed by human activity.

Just because you can't see them doesn't mean they aren't there.

Another possibility; make them hidden like submarines, unobservable except to units in a 2 tile radius. Except hidden units will still probably scare the AI.

Part of the problem is that 1-move worms really aren't scary at all cos even infantry can outrun them; again with the double moves in deep desert suggestion.
 
if a sandworm burrows in the desert and doesn't eat anyone, is it really there?

Why yes, (types ctrl-z) look! There they are.

Part of the problem is that 1-move worms really aren't scary at all cos even infantry can outrun them; again with the double moves in deep desert suggestion.

I have been down this road with dangerous animals having a high movement rate. Actually literally "down this road". I am not sure if you have played my Mad Max mod, Fury Road. There are ruined highways. There are dangerous barbarians. It was a common complaint that barbarians would zip down the roadway out of fog, and kill a unit before the player could react. In that case the solution was a custom sdk mod to disallow barbarians from using road movement.

The point is not so much that you can or cannot outrun them, the point is you have to change your plan when they appear. If you had a scout going somewhere, you may have to go somewhere else. Certainly if you had a settler you would go somewhere else; too valuable to risk. Even workers completing a several turn improvement may have to cut and run.
 
Top Bottom