Better Ai? If you're 14...

Good to see that you still chose to read this thread after its start jdog.

I agree with the idea that a civilisation that has a huge power advantage over an enemy should at some point stop building units even if it's still at war while a civilisation that can barely hold its ground should only stop building units when it can't afford another one (all of this when at war).

So I would advocate a relation between the power advantage and the percentage of the economy that a civilisation is willing to invest in units to win the war. Something like: If civ A has a power ratio of x to 1 against civ B (and both are at war), then it is willing to invest max ( 50 - 7 * x , 30) % in units. And another adjustment when the war is a limited war, maybe then it should only be max (40 - 7 * x , 20) %. The formulas are just ideas of course as I'm not sure what percentage of the economy the AI typically invests in units. They are less efficient at defending their empire so human standards are a bad basis.
The idea is just to avoid needless unit investments when the enemy can easily be beaten.

All of the above of course assumes that the power values are calculated more accurately than they presently are.
 
I'm quite reticent to believe that it will be easy to find a minimally acurate formula for what a army really worths , atleast if we base it alone in ad hoc and roleplay considerations or simply on the strenght of the unit. In any way a 0 xp rifle is worth the same of a CG III rifle in a a fort or a cannon have the same value as a ironclad or a figher ( in spite of having the same nominal strenght ). Firaxis decided to use a simple database method with most likely post beta-testing values of strenght for the units with the objective to create something resembling a acurate avaliation of a unit , and, in spite of not agreeing fully with that aproach, it may be more acurate that simply looking at the units strenght.

@ jdog

My point in talking about dagger was more to remember that the AI already does decide to enter a war without prep in some cases. And , in spite of the neither the original intention behind dagger nor the way it goes now serve to do what yakk was talking about ( peaceniks with non military UU ( read Mahatma ) will never use it and , like you said, no dagger after industrial age starts ), it can be expanded/ serve as template to meet the propose of a AI saying to itself "Ok, I don't like that guy and I have a lot more power than him... let's just grab some units and give him a cold start attack instead of waiting for 30 turns of needless buildup that can make the offensive go down"

P.S About blake and warmongering..... well, you might find elucidative to read one of the SGs he hosted while still making his version of Better AI ( in fact it was played with warlords better AI ), the Angry Korea Man . Just reading the variant will tell you much :p Really, it is a very fun SG to read :D
 
Something I wanted to mention... for the "RP" gamer that isn't trying to make it about winning, but more about fun... it's clear that you can escalate the difficulty/challenge of the AI to the point where it is not fun to play against... the obvious solution is to choose a difficulty that provides sufficient challenge while still being "fun". This will vary by player and may need experimentation. For me right now it's "noble"... I don't have to worry about playing optimally, but the AI still gives me a decent run for my money. If I get too good at beating it, and become bored, I may escalate the level.
 
Something I wanted to mention... for the "RP" gamer that isn't trying to make it about winning, but more about fun... it's clear that you can escalate the difficulty/challenge of the AI to the point where it is not fun to play against... the obvious solution is to choose a difficulty that provides sufficient challenge while still being "fun". This will vary by player and may need experimentation. For me right now it's "noble"... I don't have to worry about playing optimally, but the AI still gives me a decent run for my money. If I get too good at beating it, and become bored, I may escalate the level.

I agree with most of this. It is great that Better AI makes the 'AI' a better warmonger or indeed a better builder, but it is just as important to keep the differences between the leaders. So, for example, Napoleon becomes better at what makes Napoleon Napoleon and Gandhi becomes better at what makes Gandhi Gandhi etc.

I would vote for maintaining these differences even if it means that some leaders by maintaining their personalities will likely never win.
 
Something I wanted to mention... for the "RP" gamer that isn't trying to make it about winning, but more about fun... it's clear that you can escalate the difficulty/challenge of the AI to the point where it is not fun to play against... the obvious solution is to choose a difficulty that provides sufficient challenge while still being "fun". This will vary by player and may need experimentation. For me right now it's "noble"... I don't have to worry about playing optimally, but the AI still gives me a decent run for my money. If I get too good at beating it, and become bored, I may escalate the level.
By the way, a problem might be the way the leaderheads are set up in the XML - the values were set to induce a certain behaviour with the BTS AI. If the AI changes and makes them evaluate situations differently, it might be necessary to review the XML settings for the leaders, akin to the way Blake changed the handicap infos for Better AI.

Cheers, LT.
 
I've done a little on the build-up period front already, cutting it in half for powerful civs ... this could probably be expanded.

It'd be nice if this was made part of leader personality. For example, cold war leaders might have a longer military build up, while leaders known for their surprise attacks in history might have a shorter military build up.
 
I was going to post this before but never got around to it. In my last game I got behind in unit technology and had to buy, trade and steal to get back to being competitive. Most of the game Rome had a much bigger army. My colony wasn't technologically advanced since I had traded and stole for some key technologies and had no tech brokering on. They ended up building medieval units during the industrial age and never building up their infrastructure and thus never advancing. I had to give them lots of workers just to get them to accomplish anything. Now a human player if they were behind in technology and had a power disadvantage they would give up on unit building units and to whatever they could to get technology and hope they do that before someone takes them out. That's a hard strategy for an AI to understand. When should you give up and do the opposite of what you'd normally do?
 
I'm quite reticent to believe that it will be easy to find a minimally acurate formula for what a army really worths , atleast if we base it alone in ad hoc and roleplay considerations or simply on the strenght of the unit. In any way a 0 xp rifle is worth the same of a CG III rifle in a a fort or a cannon have the same value as a ironclad or a figher ( in spite of having the same nominal strenght ). Firaxis decided to use a simple database method with most likely post beta-testing values of strenght for the units with the objective to create something resembling a acurate avaliation of a unit , and, in spite of not agreeing fully with that aproach, it may be more acurate that simply looking at the units strenght.

I really don't think that the database values were acquired by lengthy testing methods. I think the designers did this very quickly without much thought. Something like: we give units a power rating equal to their strength rating times 1000 with some small adjustments when a unit has some special strengths. It seems that offensive units are typically given a slightly higher power rating than defensive units which makes sense as they typically are more important for the success in war.

I don't think the designers realised that a units of strength 10 is more than twice as valuable than a unit of strength 5. And even if they realised that, they didn't realise the large effects for the power estimations and war declarations.

The database figures can be improved a lot by making power closer to 1000 times strength ^ 1.5 (or maybe another even better exponent than 1.5). Some small adjustments for some units can be made if we think that some unit is more important for the war effort than this first approximation would suggest.

It's a bit harder to also take into account the experience of the unit. If the experience of the unit can be tracked ingame, then a power value of

((1 + 0.1 * sqrt(experience unit - 1)) * strength ) ^ 1.5 would be a better approximation of the power of the unit.

Explanation:
* sqrt stands for 'square root'
* sqrt (experience unit -1 ) calculates the number of promotions available to the unit from its experience value. An experience total of 5 leads to a value of 2. An experience of 8 to a value of 2.65 as the unit is in between 2 and 3 promotions.
* (1 + 0.1 * sqrt (experience unit -1)) * strength gives the units a 10% bonus in base strength per promotion. The ^1.5 is taken over the entire value.

Note that other adjustments have to be made for aggressive, protective and charismatic civs, but it's not hard to adjust the formula to take that into account. It's also very easy to apply the same adjustment of experience on the power of a unit on unit power values from a database. The only thing that I don't know is whether the experience values from units can be taken from the game easily.

The power effects of production and technology also have to approximated better. It's really not hard to come up with decent formulas except that I don't know how hard it is to get some information from the game like empire wide production, or average experience of units which are created (which includes effects of traits, wonders and great instructors).
 
((1 + 0.1 * sqrt(experience unit - 1)) * strength ) ^ 1.5 would be a better approximation of the power of the unit.

Might want to change that to:

((1 + 0.1 * sqrt(abs(experience unit - 1))) * strength ) ^ 1.5

abs =absolute value.
Otherwise units with no experience have nonreal numbers...:lol:
 
Otherwise units with no experience have nonreal numbers...:lol:

So when your enemy builds units without a barracks, then they'll have unreal power.

You're right of course.
 
Ok, Roland , now we have something more solid to discuss ;) But I'm still quite without ideas of how to make diferences between units of diferent enviroments that by acident have the same strength. For a example Cataphracts, Cannons, Ironclads, Fighters, Conquistadores, Cuiraseers and Grenadiers have all str 12... and it isn't exactly easy to say that all this units are worth the same ;) This especially regarding the diference between Cuiraseers and Conquistadores, that would return the same value using your sketck formula above, in spite of the obvious fact that Conquistadores are a stronger unit than its non-UU counterpart. And this would probably be extremely hard to quantify
 
Ok, Roland , now we have something more solid to discuss ;) But I'm still quite without ideas of how to make diferences between units of diferent enviroments that by acident have the same strength. For a example Cataphracts, Cannons, Ironclads, Fighters, Conquistadores, Cuiraseers and Grenadiers have all str 12... and it isn't exactly easy to say that all this units are worth the same ;) This especially regarding the diference between Cuiraseers and Conquistadores, that would return the same value using your sketck formula above, in spite of the obvious fact that Conquistadores are a stronger unit than its non-UU counterpart. And this would probably be extremely hard to quantify

Yes, some small changes in the unit power ratings have to be made based on how useful the units are to the war effort. That's not an exact science and it's not purely based on in game experience either as the AI cannot use unit strengths as well as we humans can. But still, a conquistador is clearly stronger than a cuirassier for the AI. I'm not advocating trying to create a formula for each and every bonus as that's almost impossible. The strength of a bonus depends very much on all the other units that the unit will encounter so it's hard to give it a value independent from considering those other units. This makes such an independent formula for bonuses not something that will work well.

It's better to just create a database where a formula like 1000 * strength ^ 1.5 is a first approximation.

For instance for grenadier, cannon, cuirassier and conquistador
Base power value for a strength 12 unit: 1000 * 12 ^ 1.5 =(approx) 41500
Base power value for a strength 2 unit: 1000 * 2 ^ 1.5 =(approx) 2800

So we could do something like:
warrior: 2800
grenadier: 41500
cannon: 45500
cuirassier: 45500
conquistador: 50000

There are a few jumps of +10% in power in there. The conquistador is valued about equal to a strength 13.5 unit in the formula. Maybe not perfect, that could be discussed. The formula 1000 * strength ^ 1.5 is just a first step. Refinements could be made to value the power of collateral damage (cannon), 2 movement and retreating (cuirassier) and a unique unit strength (conquistador) depending on how we perceive those.
Maybe, I'm undervaluing the grenadier a bit or overvaluing the mounted units a bit. The grenadier is pretty useful too and the mounted units have a major weakness in the rifleman. But it's just an example to show you what we could do.

Experience effects would then be added as follows:

((1 + 0.1 * sqrt(abs(experience unit - 1))) ^ 1.5 * 'power value from database'

(Although, I'm not sure how hard it is to get the experience values of all the units from the game. Maybe that part is not possible and that effect on power would be ignored which would typically undervalue civilisations with the aggressive trait and human civilisations.)

By the way, in the present power values file, the grenadier, cannon, cuirassier and conquistador are valued the same (12000) and all four of them are valued 6 times as powerful as the warrior (2000).
 
By the way, in the present power values file, the grenadier, cannon, cuirassier and conquistador are valued the same (12000) and all four of them are valued 6 times as powerful as the warrior (2000).

Power values file?

Just want to sure I understand ... in Civ4UnitInfos.xml, each unit has an iPower rating which at least for land units seems to be the same value as their combat strength. Those value get added directly to a player's power, without any adjustment currently.

One think I'm looking at is splitting power into its constituent pieces to store separately: economic/production power (pop and buildings), land power, air power, sea power, etc. This can easily be done.

It would also be possible to do power based on experience ... power gets +iPower when a unit is created, -iPower when destroyed. Would have to add a small + when units gain experience, but should be easy to get right.
 
Just for the record, this work. I see humans do that in a regular basis to non-Better AI Immortal and Deity AI and I've done it myself a couple of times as well. There was even a player that posted a game this week on Strategy and tips that built 80 axes in a standart continents map and drove 2 AI out of the game with it. It might not be realistical, but it definitely works in game.

Hmm, that sounds awfully familiar...where have I seen that before :lol:?!

Building more units is good for the AI. I've not played betterAI in a long time (just wait till I get my new computer though...!), but my understanding is that it doesn't change the XML-based data for them much. Does diplo not still work? That was always the way to counter unit spam before...

That aside, as others have pointed out the rules of the game are such that backwards troops still win in #'s. Not just take a city or two, but if properly applied completely cripple or eliminate their target. Aside from my 80 axe rush on immortal, I use horse archers in this role regularly. Sure, the AI is ahead 6+ techs, but then a couple cities get razed, their army scattered, and they slow down.

Tech leads don't mean much when your last city falls. This game forces balance and getting cities taken off of your is a good indication that balance (or diplo) is lacking in your empire.

Just for fun, see how those 150 units do against 30 drill defenders, about 10 siege, and enough flanking troops to kill its siege off. For maybe about 50 of your own units or less, you can probably kill all 150 invaders. Of course nukes will kill any stack later on.

I don't see the issue with improving the AI's warring. It's teching was always terrible, but my understanding is that betterAI improves even this somewhat. But Civ IV isn't about teching, it's about clearing a victory condition. This can be done even at large tech deficits. In addition to the axe game, I had an immortal U game where I used cavalry, arty, and anti-tanks to take on AIs that were well past industrialism. That wasn't just a city or two taken, it was DOMINATION, the complete subjugation of multiple civs with 10+ techs on me. That's how this game is...there's a lot of ways to win and it sounds to me like betterAI goes for one of the more straightforward approaches.
 
Power values file?

Just want to sure I understand ... in Civ4UnitInfos.xml, each unit has an iPower rating which at least for land units seems to be the same value as their combat strength. Those value get added directly to a player's power, without any adjustment currently.

Yes, that's the file. The power isn't always equal to the strength rating, but the difference is negligible. An axeman for instance has a slightly higher power rating (6) than strength rating (5) which is probably a good decision as the unit is a bit more valuable for the war effort than its strength rating would suggest.

I would like the power rating to rise more quickly than the strength rating as a unit with strength 20 will typically beat more than 2 strength 10 units.

I used the power description like it's shown in the demographics where it's multiplied by 1000 to get a 'soldiers' value. The multiplication by 1000 of course is meaningless for comparisons between civilisations power. So you can scrap 3 zero's from any number that I used in my previous post. It's just the way that players are familiar with the power score.

One think I'm looking at is splitting power into its constituent pieces to store separately: economic/production power (pop and buildings), land power, air power, sea power, etc. This can easily be done.

The splitting in land, air and sea power could be very useful for the AI, especially when other code is also changed so that the AI responds to changes in one of the three power ratings of its enemy in a more sensible way. It's awful to see an AI not build land units to stop an invasion because its building caravels to stop 3 privateers or to see it build land units while it's being mercilessly bombed from the air.

I would suggest to base economic/production power on the production value of a civilisation instead of pop and buildings. Something like (total production / production cost of highest power unit) * power of highest power unit * Game speed factor. The 'Game speed factor' could be 5 to 10 turns for normal speed and be adjusted for the other game speeds. An experience factor of the units that are going to be produced might also be possible. A civilisation using theocracy and vassalage should get a higher economic power as its units will be better. A civilisation that has many settled Great instructors could also get a bonus. Ideally, the power of the production value of a city would be multiplied by an experience factor of the units that are going to be created in that city before all of these city powers are added together. So a city with a barracks and 2 settled great generals and the Pentagon in the civilisation using a theocracy civic would add a lot more power than a city with the same production output but no experience bonuses.

The economic power could also be calculated separately using the highest power land, sea and air unit so that the economic power could be added to each of these types of powers separately.

It would also be possible to do power based on experience ... power gets +iPower when a unit is created, -iPower when destroyed. Would have to add a small + when units gain experience, but should be easy to get right.

Great. The +iPower based on experienced should of course be based on the base power of the unit that gains the experience.

I wonder how much processor time it would take. Can the power values of already constructed units be stored or do they have to be recalculated each time? The calculations aren't huge (for present day computers), but if they have to be done very often, then it might take some time anyway.
 
I used the power description like it's shown in the demographics where it's multiplied by 1000 to get a 'soldiers' value. The multiplication by 1000 of course is meaningless for comparisons between civilisations power. So you can scrap 3 zero's from any number that I used in my previous post. It's just the way that players are familiar with the power score.

I always wondered where the troop number came from ... you learn something new everyday!

I would suggest to base economic/production power on the production value of a civilisation instead of pop and buildings. Something like (total production / production cost of highest power unit) * power of highest power unit * Game speed factor. The 'Game speed factor' could be 5 to 10 turns for normal speed and be adjusted for the other game speeds. An experience factor of the units that are going to be produced might also be possible. A civilisation using theocracy and vassalage should get a higher economic power as its units will be better. A civilisation that has many settled Great instructors could also get a bonus. Ideally, the power of the production value of a city would be multiplied by an experience factor of the units that are going to be created in that city before all of these city powers are added together. So a city with a barracks and 2 settled great generals and the Pentagon in the civilisation using a theocracy civic would add a lot more power than a city with the same production output but no experience bonuses.

Yes, this is a good idea ... loop through cities and add up their "military production power." Would need to include city bonuses for military unit production as well. This same power rating for each city would then also be very helpful for the AI to prioritize where to build units.

Great. The +iPower based on experienced should of course be based on the base power of the unit that gains the experience.

I wonder how much processor time it would take. Can the power values of already constructed units be stored or do they have to be recalculated each time? The calculations aren't huge (for present day computers), but if they have to be done very often, then it might take some time anyway.

This won't be a significant source of slow down ... recalculation is only necessary when the unit gains experience or dies, if that happens even 1000 times a turn you wouldn't be able to tell. What really slows the game down are the ~10million calls to CvUnit::canMoveInto in the late game and the thousands of plot group recomputations whenever a road is completed/pillaged. That's the painful part.
 
I always wondered where the troop number came from ... you learn something new everyday!

Putting 3 zero's after a number is cool in computer games. ;)

Yes, this is a good idea ... loop through cities and add up their "military production power." Would need to include city bonuses for military unit production as well. This same power rating for each city would then also be very helpful for the AI to prioritize where to build units.

If city specialisation is implemented at some point, I could also see it used to find a city for the West Point or something like that.

This won't be a significant source of slow down ... recalculation is only necessary when the unit gains experience or dies, if that happens even 1000 times a turn you wouldn't be able to tell. What really slows the game down are the ~10million calls to CvUnit::canMoveInto in the late game and the thousands of plot group recomputations whenever a road is completed/pillaged. That's the painful part.

Just wanted to make sure. I guess that the part of the program you're mentioning has something to do with a pathing algorithm and those can be slow when used that often.
 
It would also be possible to do power based on experience ... power gets +iPower when a unit is created, -iPower when destroyed. Would have to add a small + when units gain experience, but should be easy to get right.

That's a fair approach, but it doesn't take account of bonus promotions from events/traits/etc. Also, Drill IV is worth substantially more than Drill I, whereas Combat IV is worth slightly less than Combat I. Additionally, experience becomes less valuable after you get more of it.
 
So, I was thinking about the power problem.

Instead of doing a "real power value" for a unit, what if we kept the "unit power value" to be a proxy for how much it costs to build (which is what the current unit power value is), and instead had technology multiply this?

Ie, you have a unit power value, and a technology leverage power value (with maybe infrastructure adding to the technology leverage value). You then take Unit Power * Tech Leverage to be your 'actual' power.

So when you research Riflery, your Technology leverage goes up a chunk -- an instant power spike, even if you don't upgrade any units, representing the availability to upgrade units. Then as you upgrade units to Riflemen, your power grows.

This makes "stealth power" harder to pull off (having a huge pool of warrior units that you upgrade to high-end units).

There is already an iPower field in technology. We could probably define some constant K, then take
(K + Sum (iPower technology)) * (Sum( iPower units ) + Sum( iPower buildings ))
as our 'better approximation to power'.

I suspect with a reasonable choice of K, the result can be close to Sum( (unit iPower)^1.4 ) or what have you, by making the left term (K + Sum( iPower Technology) ) grow like the iPower^0.4 of units the technology generates (very roughly)...

That make any sense?
 
Back
Top Bottom