A "real" AI cheat

I like Roland's model, but I would suggest a slight modification: Let's make the patrol's behaviour not a function of its hitpoints but of the actual combat odds.

Thanks.

I understand that you would want to change it in that way. It is in line with the rest of your logic, the way you want the patrol function to work. However, I don't know if it will work too well in this game. Some units will have to behave somewhat suicidal in order that others may be victorious.

My C++-skills are also very limited, but in my tests I haven't encountered any problems yet. Maybe there are better ways to implement it. So what do you think about that? How would you adjust the "coward-threshold" (40%)? Did I miss any loopholes for exploits?

Every game rule can be exploited, the only thing that we can achieve is to limit the amount of exploitation. In this case a single battleship (or missile cruiser) could pillage the sea food resources protected by several destroyers while those destroyers just watch. In civ4, even a small strength difference leads to lopsided combat odds.

The reason that I would go with the hitpoint based percentage is because it is based on the idea already used in aerial interception. It allows softening of the enemy (which is sometimes needed), but it stops severely hurt units from automatically intercepting (in a suicidal manner). I also don't mind the situation where a single pillaging destroyer kills several healthy frigates on patrol duty (or the other way where a single destroyer on patrol duty kills several pillaging frigates). So I don't try to stop that situation which you do try to stop.
 
Yes, 40% is probably way too chicken due to the lopsidedness of combat odds. Maybe 20-25% would work better here.

Why would a 40 HP Destroyer not intercept a pillaging Trireme? (mega-contrived ;))

The reason why I do mind the situation where a single pillaging Destroyer kills a stack of healthy wooden boats, is because I assess its potential for exploitation much higher. Especially on lower difficulty levels and with a clever focus on certain tech paths a human can create a huge gap between the strength of his naval units and that of a competitor. In every game there is one backward AI or one that neglected certain techs or one that lacks the necessary resources. So the "1 Destroyer vs stack of Caravels" situation is not that unrealistic and doesn't automatically mean that one has won the game at such a moment. But letting those healthy Caravels go kamikaze on the Destroyer would mean offering an excellent xp-milk opportunity which a human player could exploit to push his naval advantage even further in just a couple of turns. These thoughts assume that the AI eventually learns to use Sea Patrol, but it might also be a MP problem.

I'm sorry, I can't really follow your comparisons to the Air Patrol function, it certainly had the same problems if Fighters could fly more than 1 mission per turn.
 
Yes, 40% is probably way too chicken due to the lopsidedness of combat odds. Maybe 20-25% would work better here.

Why would a 40 HP Destroyer not intercept a pillaging Trireme? (mega-contrived ;))

The reason why I do mind the situation where a single pillaging Destroyer kills a stack of healthy wooden boats, is because I assess its potential for exploitation much higher. Especially on lower difficulty levels and with a clever focus on certain tech paths a human can create a huge gap between the strength of his naval units and that of a competitor. In every game there is one backward AI or one that neglected certain techs or one that lacks the necessary resources. So the "1 Destroyer vs stack of Caravels" situation is not that unrealistic and doesn't automatically mean that one has won the game at such a moment. But letting those healthy Caravels go kamikaze on the Destroyer would mean offering an excellent xp-milk opportunity which a human player could exploit to push his naval advantage even further in just a couple of turns. These thoughts assume that the AI eventually learns to use Sea Patrol, but it might also be a MP problem.

I'm sorry, I can't really follow your comparisons to the Air Patrol function, it certainly had the same problems if Fighters could fly more than 1 mission per turn.

The reason for wounded units not intercepting could be many: repairs, technical problems, non-functioning radar. The idea wasn't based on a strength comparison between the units like you would want to.

Airplanes can perform more than one mission when on intercept duty, but not when bombing. The comparison with the aerial interception mission that I'm making in my previous post is about the chance to intercept. An airplane at 40 hitpoints has a 40% chance to intercept. I'm just following the same model.

In the sea patrol mission, softening up the enemy is needed so that a single battleship or missile cruiser cannot pillage all tiles protected by a stack of destroyers or so that a single bombing mission doesn't weaken the patrolling units to the point that they're not daring to intercept. That would happen in your model, no matter where the cut-off percentage is going to be.

A model based on chance (to intercept) is less exploitable because it's unpredictable. But of course, 'my model' still allows the strong ship kills lots of weak ships thing. However, I don't have a problem with that even if it could in some cases lead to a strong player getting some quick xp and quick kills (instead of lower amounts of xp and slower kills over several turns).

We're mainly desiring different models not because of some logical argument but just because of some gameplay preferences.
 
Would it be possible to use whichever is higher for the chance to intercept? (the percent chance of survival vs the percent HP left)

A damaged Destroyer with a high victory chance against a weak boat (like a trireme as you said) would still likely intercept.
A full health Destroyer would also try to stop a Battleship since it has 100% health (and there's no reason for it to avoid combat if its survival is sufficiently low since if it's alone the Battleship could kill it outright)

Something other than HP needs to be taken into account at least, since this is different from air combat, namely in that there are only 2 different aerial defenders. A number of Fighters against a Jet will fair much better than Caravels against a Battleship.

This would still allow situations where an advanced boat could kill an earlier one, but this is less of a problem than the retreating Subs and single Missile Cruisers killing numerous Missile Cruisers. If your navy could be overpowered like that, then allowing only one attack would just keep it from pillaging until the next turn (or longer if you don't retreat), just to protect some inferior units. I believe this is where it is acceptable to have a level of risk with patrol compared to placing units on resources. If an enemy's naval units are that powerful you need to act to close the gap or be prepared to lose those resources.

This would also have the least change occur with multiple ships on both sides, since the highest chance will be used.
 
Would it be possible to use whichever is higher for the chance to intercept? (the percent chance of survival vs the percent HP left)

Welcome to civfanatics! :dance::band:[party]
I assume you've been lurking around here for a while. This is another model that I wouldn't object to with the slight modification of taking the maximum of twice the chance of victory and the percent HP left (50% chance of victory leads to 100% chance of interception).

Note that DanF5771 didn't use a chance to intercept. He used a threshold chance. Above that chance, there would be an interception. You could change that model slightly by for instance calculating the chance to intercept as equal to twice the chance of victory and that would remove any predictability from his model.



To anyone who has trouble keeping his/her sea resources or coastlines safe: make more use of the aerial reconnaissance mission. The area that it uncovers is huge. With several planes, you can see an area of some 16 tiles outward from your cities and you can also use allied cities (cities from civilisation with whom you have open borders) for this reconnaissance. The reconnaissance mission uncovers an area of 13 times 13 tiles centred on the tile of the mission which can for instance be 10 tiles outward from your cities for jet fighters. With such a huge visibility, you can see an attack fleet or invasion fleet coming and take precautions. That's the way that I like to defend my coasts instead of large numbers of ships spread around my coast line. You can't defend every coastal tile against that potential invasion fleet of 12 ships if you don't know where it is coming.

A few pointers about the reconnaissance mission:
1) Use shift to repeatedly give the order on the same tile (say 20 times) and you won't have to reorder the reconnaissance every turn. Only after 20 turns, you'll have to reorder the mission. The CTRL-a command at the start of the turn performs all commands that have been issued in previous turns and thus will let all of your fighters/jet fighters perform their reconnaissance mission for that turn, giving you massive visibility.

2) The reconnaissance mission is bugged. It works like it were a land based reconnaissance unit. A plane can see further when it centres its reconnaissance mission on a mountain than when it centres it on a hill. And it can see further when centred on a hill, then when centred on flatland.
Mountain: allows you to see over everything
Hill: allows you to see over everything but mountains or wooded hills
flatland: allows you to see over flatland without forests or jungles and over water
water: allows you to see over water
(or something like that)
So just explore above high land (or get solver to fix this ;) ).
 
I've been mulling this thread over, and while this idea doesn't exactly fit into the current discussion - I thought I would throw it out there anyways ;-)

I've been considering reducing movement of Ships that are damaged, this would also play into limiting a ships ability to pillage en-masse after surviving a few combats.
Perhaps something along the lines of:
Code:
if ( currHP < 60 )
{
    maxMove *= MAX(1, ( currHP + 40 ) / 100);
}

maxMove could be recalculated after any naval combat (including pillage defense).

Also ships tend to have ~twice as much Move compared to land units, any pillage action could cost 2MPs instead of 1.

[EDIT]
I read a number of the older Naval combat threads where there were many ideas discussed and problems raised with the current limitations and exploits available for Naval warfare.

It might be worthwhile to consider doubling the cost of Naval movement within culture soaked water tiles of someone you are at war with. Though this is likely far beyond the scope of this thread.
 
:beer: BwdYeti!

1) Use shift to repeatedly give the order on the same tile (say 20 times) and you won't have to reorder the reconnaissance every turn. Only after 20 turns, you'll have to reorder the mission.

The most valuable 2 sentences of this 200+posts thread! How could I not think of SHIFT? :hammer2: Thanks a lot!

On topic: IMHO one of the main goals of the Sea Patrol function is to save hammers which one would need to invest in Work Boats again, after they got destroyed by pillagers. So this is where my motivation for the more conservative approach originates (ok. 40% was too conservative). That approach/model strongly focuses on the combat odds in order to minimize the risk to lose more hammers than necessary. I would rather have the enemy Battleship pillage all of my 3 Fishing Boats than see 3 of my 200 :hammers: Destroyers unsuccessfully trying to stop it. I'd strongly prefer to deal with the Battleship during my turn, when I have several options like softening it with Airships/Airplanes/Missiles/Flanking Subs or moving in healthy units from somewhere else. The mentioned risk is of course equal to the combat odds of the pillager, which in turn strongly depend on the hitpoints of the defender (2.5-ic relation) so hitpoints are already factored in as well.

By adjusting the threshold, one should be able to find an optimum for this risked vs saved hammers balance. The problem here is only, that the Work Boats cost 30 :hammers: throughout the whole game whereas the units to protect them get more and more expensive. :confused: Right now I'm testing something like 23% to limit the number of sacrificed patrols to one/two so that the second/third patrol succeeds in killing the pillager.

I'm not sure whether adding some kind of randomness to the fight-or-flight decision of the patrols would be welcome, because I believe there is enough RNG involvement already within the actual combats.

After reading Stormreaver's article about (the borked :crazyeye:) Air Combat (thanks for the tip Roland) I even more dislike drawing any parallels between the two patrol missions. Because of the high iRoundDamage (50 HPs) an inferior, but healthy Airplane has a very good chance of 26% to destroy an aggressor of double strength and a 56% chance to inflict major damage to it so that following combats are successful and the unit didn't suicide for nothing. These kind of "lucky punches" would occur a lot less often during sea combat where iRoundDamage is a function of the units strength. That's why I like "flight" better than "fight" for patrolling ships.


Balderstrom: The superior mobility of modern naval units is indeed the basic evil here, but I'm a bit confused when looking at your code.
Whats up with the MAX()? If I understand it correctly there wouldn't be any decrease for damaged units.
Another lesson I learned during our adventures with Collateral Damage is that
int iModifier *= float fX is in fact equal to iModifier = iModifier*trunc(fX) and thus for fX < 1 iModifier becomes 0!
Thats why the promotions Drill2, Drill3, Drill4 currently make all units immune to collateral damage (:blush::blush::blush:).
 
I didn't dig around in the code to pull out the actual variables used in the DLL.

Shouldn't write out code when tired, I originally had it as a "? :" statement, but changed it to an IF for others readability heh, and merged it wrong.
Code:
maxMove *= ( currHP > 60 ) ? 1 : ( currHP + 40 ) / 100;
maxMove = MAX( 1, maxMove);
Naval units below 60% Health, would have reduced mobility.

If used, would need to be inserted into the call_Damage and call_Heal functions to restore move.
 
The most valuable 2 sentences of this 200+posts thread! How could I not think of SHIFT? :hammer2: Thanks a lot!

Heh, you're welcome. :D

On topic: IMHO one of the main goals of the Sea Patrol function is to save hammers which one would need to invest in Work Boats again, after they got destroyed by pillagers. So this is where my motivation for the more conservative approach originates (ok. 40% was too conservative). That approach/model strongly focuses on the combat odds in order to minimize the risk to lose more hammers than necessary. I would rather have the enemy Battleship pillage all of my 3 Fishing Boats than see 3 of my 200 :hammers: Destroyers unsuccessfully trying to stop it. I'd strongly prefer to deal with the Battleship during my turn, when I have several options like softening it with Airships/Airplanes/Missiles/Flanking Subs or moving in healthy units from somewhere else. The mentioned risk is of course equal to the combat odds of the pillager, which in turn strongly depend on the hitpoints of the defender (2.5-ic relation) so hitpoints are already factored in as well.

By adjusting the threshold, one should be able to find an optimum for this risked vs saved hammers balance. The problem here is only, that the Work Boats cost 30 :hammers: throughout the whole game whereas the units to protect them get more and more expensive. :confused: Right now I'm testing something like 23% to limit the number of sacrificed patrols to one/two so that the second/third patrol succeeds in killing the pillager.

I'm not sure whether adding some kind of randomness to the fight-or-flight decision of the patrols would be welcome, because I believe there is enough RNG involvement already within the actual combats.

The reason for adding randomness is that unpredictability is hard to exploit. It would be sad if after some nice programming exploit-like behaviour like:

'a single bombing run on 8 destroyers makes them all to scared to intercept the single pillaging battleship' would occur (just an example of what could happen).

Note that the loss for destroying workboats is actually significantly higher than 30 hammers. You'll also lose several turns of food production, especially if multiple workboats have been pillaged in close proximity. And that could result in losing one or several citizens from a city. That's a lot of damage. And the AI is probably even slower in repairing the damage as a human player. The AI probably won't interrupt current building projects to quickly build some workboats in nearby cities.

After reading Stormreaver's article about (the borked :crazyeye:) Air Combat (thanks for the tip Roland) I even more dislike drawing any parallels between the two patrol missions. Because of the high iRoundDamage (50 HPs) an inferior, but healthy Airplane has a very good chance of 26% to destroy an aggressor of double strength and a 56% chance to inflict major damage to it so that following combats are successful and the unit didn't suicide for nothing. These kind of "lucky punches" would occur a lot less often during sea combat where iRoundDamage is a function of the units strength. That's why I like "flight" better than "fight" for patrolling ships.

That's clear. Although the damage done by pillaging on the sea is probably more costly than the bombing damage done by fighters. So interception is in some way also more important.

If I had to redesign the whole thing from scratch, then I would do it very different. Are we still looking for something that is acceptable for the unofficial patch? The current ideas are becoming too involved to seem acceptable for the unofficial patch.

Another lesson I learned during our adventures with Collateral Damage is that
int iModifier *= float fX is in fact equal to iModifier = iModifier*trunc(fX) and thus for fX < 1 iModifier becomes 0!
Thats why the promotions Drill2, Drill3, Drill4 currently make all units immune to collateral damage (:blush::blush::blush:).

Yes, I haven't heard from Solver in a while on this issue. Is he really leaving it in that state? I wouldn't want to use the unofficial patch with such bug-like behaviour. And many posters won't even know that this bug is present because they're not closely watching the damage of collateral damage attacks.

Balderstorm: Interesting ideas. It could be nice for a mod. I remember the slower movement for ships in coastal areas for some mods in civ 3 and the slower movement of wounded ships in civ 2.
 
yet another contrived scenario wiht just 2 Fishing Boats, 1 enemy Battleship (Drill or Barrage promoted), 8 patrolling Destroyers (more for fun):
1. Stack of patrolling 8 Destroyers gets bombed down to 70 HP each.
2. Battleship attempts to pillage first WB, RNG says "no interception", WB pillaged
3. Battleship attempts to pillage second WB, RNG says "Intercept!", Battleship kills damaged Destroyer1
4. Battleship attempts to pillage second WB, RNG says "Intercept!", Battleship kills damaged Destroyer2
5. Battleship attempts to pillage second WB, RNG says "Intercept!", Battleship kills damaged Destroyer3, with 5 HPs left
6. Battleship attempts to pillage second WB, RNG says "no interception", WB pillaged (wouldn't work with BwdYeti's combined model)
7. Battleship moves back to Fort and is safe
= 3 Destroyers and 2 WBs lost, nothing gained :( ;)
 
That's partly why I thought combat odds should be used as more than just a threshold, since if just HP is used there's always the chance an injured unit that can still win won't intercept.

If I had to redesign the whole thing from scratch, then I would do it very different. Are we still looking for something that is acceptable for the unofficial patch? The current ideas are becoming too involved to seem acceptable for the unofficial patch.

This should be taken into account. If we're looking for a solution that would fit with the unofficial patch then my suggestion is likely too involved. The safest idea along those lines might be not using HP at all, and just using combat odds * 2. This might still be too far from the original, though (and for better or worse also protects low tech boats from advanced ones at the cost of the resources they're covering)

If not of course we should look for the best solution we can.
 
yet another contrived scenario wiht just 2 Fishing Boats, 1 enemy Battleship (Drill or Barrage promoted), 8 patrolling Destroyers (more for fun):
1. Stack of patrolling 8 Destroyers gets bombed down to 70 HP each.
2. Battleship attempts to pillage first WB, RNG says "no interception", WB pillaged
3. Battleship attempts to pillage second WB, RNG says "Intercept!", Battleship kills damaged Destroyer1
4. Battleship attempts to pillage second WB, RNG says "Intercept!", Battleship kills damaged Destroyer2
5. Battleship attempts to pillage second WB, RNG says "Intercept!", Battleship kills damaged Destroyer3, with 5 HPs left
6. Battleship attempts to pillage second WB, RNG says "no interception", WB pillaged (wouldn't work with BwdYeti's combined model)
7. Battleship moves back to Fort and is safe
= 3 Destroyers and 2 WBs lost, nothing gained :( ;)

That could theoretically happen, yes. But I don't think you'll do that pillage action in no 6. And even that pillage action in no 5 is risky, but of course you also know that.;)

I'm just saying that unpredictability is hard to exploit because you can't calculate the outcome and make use of that knowledge to the fullest. You'll have to guestimate. Unpredictability of course doesn't mean that bad things will never happen to your units.
 
That could theoretically happen, yes. But I don't think you'll do that pillage action in no 6. And even that pillage action in no 5 is risky, but of course you also know that.;)

Right, I would never attempt to pillage at such odds, but I was thinking about Monty (:shifty: scary thought, Monty with Battleships...).

So, maybe randomness is kind of cool--how about this condition then:
Code:
if (GC.getGameINLINE().getSorenRandNum(500, "Intercept Rand (Sea)") > getCombatOdds(this, pInterceptor)-500)
...
which would lead to the following behaviour of the patrol:
a) always intercept in cases when chance of success is higher than chance to die
b) likelihood of interception decreases linearly with the aggressor's combat odds increasing from 50% to 100%

I still have difficulties to get warm with the HP model, and I don't really know whether linearity is good here (but haven't seen any non-linear RNG stuff so far).

Regardless of what this particular aspect of any sophisticated model will eventually look like, I would love to see the disallowance of withdrawal for pillagers find its way into an unofficial patch.
 
Right, I would never attempt to pillage at such odds, but I was thinking about Monty (:shifty: scary thought, Monty with Battleships...).

So, maybe randomness is kind of cool--how about this condition then:
Code:
if (GC.getGameINLINE().getSorenRandNum(500, "Intercept Rand (Sea)") > getCombatOdds(this, pInterceptor)-500)
...
which would lead to the following behaviour of the patrol:
a) always intercept in cases when chance of success is higher than chance to die
b) likelihood of interception decreases linearly with the aggressor's combat odds increasing from 50% to 100%

I still have difficulties to get warm with the HP model, and I don't really know whether linearity is good here (but haven't seen any non-linear RNG stuff so far).

Regardless of what this particular aspect of any sophisticated model will eventually look like, I would love to see the disallowance of withdrawal for pillagers find its way into an unofficial patch.

Sorry, but I'm not very good at reading C++ code. I've not learned anything about reading C++ coding at all, ever, so I can only use my logic in trying to understand the code and in this case, that's not enough.

Is that very different from taking twice the odds to win (the intercept battle) as the chance to intercept?

If I myself would have made a model for the patrol mission, then I would have surely made a more involved model than the present one; a model that would behave a bit more 'intuitively' or 'realistically'.

If we want to 'sell' a change to Solver, then we'll have to come up with strong arguments and a simple and elegant solution that will be universally liked by the large majority of the community. That's a really tall order, probably infeasible to be honest. Solver has been pretty conservative in his changes. For instance, I think a significant part of the community will not be charmed by the idea of a completely healthy unit not intercepting a pillager. Not because of it not being realistic or something, but just because it's a large change and one that is not based on some similar behaviour elsewhere in the game.
I think we might convince the majority of the community and Solver to at least disallow retreat for the pillager. That seems pretty sensible based on the documentation in the civilopedia where the patrol ships are described as the attackers. Thus the defending pillagers should not be allowed to retreat. Furthermore, there is potential for abuse by allowing repeated pillaging moves for the retreating pillager.

If you were creating a mod, then I'd come up with very different models, much closer to what you're suggesting. (Probably the group of patrol units would all attack at once if they as a group think they can win against the pillaging group. It would surely involve some pretty complicated formulas. Maybe the patrol area would also be much larger and would also stop any enemy fleet entering the area. Could be very interesting and fun.)
 
:hmm:
If I understand this code correctly then the interceptor will always attempt interception if his odds to win are 50% or better - and if they are less the win% determines the odds of an attempt, i.e. an interceptor with a chance to win of 40% will intercept 80% of the time and interceptor with a chance to win of 1% will intercept 2% of the time.
It is actually a decent approach to include some randomness into the whole thing. I am not yet sure as to the cutoffs - I want to do some testing in to what odds are present with combinations of ships that are from somewhat similar tech levels - but in principle I'd like this :)
 
Is that very different from taking twice the odds to win (the intercept battle) as the chance to intercept?

Erm, thinking about it again, it's actually exactly the same (blue line in figure). As I mentioned, I'd rather prefer something non-linear (quadratic=red, ^4=green).

PIC.png


If we want to 'sell' a change to Solver, then we'll have to come up with strong arguments and a simple and elegant solution that will be universally liked by the large majority of the community.
Just had that song "Dreams are my Reality" going through my mind...;)

If you were creating a mod, then I'd come up with very different models, much closer to what you're suggesting. (Probably the group of patrol units would all attack at once if they as a group think they can win against the pillaging group. It would surely involve some pretty complicated formulas. Maybe the patrol area would also be much larger and would also stop any enemy fleet entering the area. Could be very interesting and fun.)

Sounds indeed very cool, but I'm afraid that would be something for an "Even better than the Better than BTS AI".

Do you think whether starting a poll to ask the community about the preferred behaviour of patrolling ships might be a good idea?
 
Erm, thinking about it again, it's actually exactly the same (blue line in figure). As I mentioned, I'd rather prefer something non-linear (quadratic=red, ^4=green).

I also like continuous functions more. But I doubt that you'd really notice the rather subtle differences ingame.


Just had that song "Dreams are my Reality" going through my mind...;)

However reasonable ones argument is, there will always be someone who opposes it. ;)

We just need to minimise opposition. Have a nuke in storage? :D

Sounds indeed very cool, but I'm afraid that would be something for an "Even better than the Better than BTS AI".

Yeah, it's seldom the lack of ideas that's the problem. ;)

However, I don't think this would be too hard for Firaxis to make if they really wanted to. It's just not part of their design philosophy. They want to keep the war element of the game simple.

Do you think whether starting a poll to ask the community about the preferred behaviour of patrolling ships might be a good idea?

I think that the majority of the community isn't really aware of the exact behaviour of the patrolling ships. That's not meant as an arrogant remark, but it's just not a heavily used feature (yes, there are always exceptions, Sirsnuggles ;) ).

Note that lack of knowledge can be an advantage when you try to convince someone. :evil: :mischief:

Also note that many posters will answer a poll before they read the first post which will mean that any convincing arguments in the first post tend to be useless. So the poll shouldn't have a question (refer to first post) so that people are forced to read the first post before they can answer. Then the first post should start with explaining the nature of the patrol mission and the issues that could result from it (without too much exaggeration, you don't want to discredit your position). And then a very simple and elegant change should follow it (that's not one of the ones we posted about above).

All of this shouldn't take too much words and be easy to read: Impatient people tend to disagree with lengthy complicated issues.

Hmm, reading the above: Good luck! :D
 
For me it's <Good Night> first. Anyway thanks for these insights into the psyche of the average civ community member. :cool:

Didn't you had learn anything of the last 11 pages about the average civ community member psyque ? ;)

Maybe i was being a bit too negative. :p
 
Back
Top Bottom