1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

A "real" AI cheat

Discussion in 'Civ4 - General Discussions' started by The Snug, Jul 4, 2008.

  1. DanF5771

    DanF5771 Emperor

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Let me come up with a truly contrived example: 2 Drill4 MCs and a Tactical Nuke ;)

    Quick test revealed that the C3-Blitz MC is lucky to kill 3 damaged MCs. (Yes, this is where Drill4 really shines, when it gets a free Blitz.)
    Result: 5 of Woody's MCs survive and all Fishing Boats stay intact --> my Patrol code saved 1390 :hammers:! I classify this as a selling point.
     
  2. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    Yes, I had also thought about the tactical nuke. Several tactical nukes on a stack of 12 MC's is always a cheap way to kill them, no matter where they are (as long as they're not protected by bunkers or SDI).


    Yes, I know that a drill IV unit performs perfectly against heavily wounded units, although in general no unit will become seriously wounded from fighting units below 50% hitpoints (and of equal basic strength). Still, the normal blitz unit will be weakened by subsequent fights and eventually die.

    My point was that the real damage is not from the patrol ships stupid reaction, but because of the halving of their hitpoints by missiles and barrage promoted units. In this case the crippled units can be easily finished because they were stupidly ordered to attack anything that tried to pillage and that's why you can do it with 1 drill IV unit. But anything could finish them at that point. Destroyers could even easily kill them and if you didn't have enough units in the neighbourhood, then they'd have to flee the scene or die the next turn. It's just their stupid order to attack anything that pillages that makes them die quicker.

    (Most contrived example: lots of bombers which can't be intercepted + 2 drill IV MC's.)

    What we're merely proving here is that the order: attack anything in the neighbourhood until you die or it dies (generalisation) is often not the best order. We don't need examples for that. It's pretty clear that the order isn't very smart. The question is: should we the exploitation of the dumb order?

    Note that if I use a tactical nuke on a city with 8 fighters on aerial interception and then send in a bunch of my own (jet) fighters on bombing/striking missions, then this aerial interception order is pretty suicidal. It's just that airplanes only have 1 movement point.
     
  3. The Snug

    The Snug The Civ Heretic

    Joined:
    Dec 5, 2003
    Messages:
    954
    Gender:
    Male
    Location:
    Seattle
    Roland, I appreciate that you came out of hibernation to post a response, But you still haven't overcome the power of the "contrived" examples. Yes, guilded missiles unbalance the equation, but the defending MC's would also have GM's that they would never be able to fire since their entire force would be wiped out by a handful of units. As to the promotions, you would achieve nearly the same results if none (both sides) of the ships possessed any promotions.

    At worst, the attacking force might lose 1-3 MC's, but they would still destroy the defending stack. The fact that cannot be gotten around, that cannot be dispelled, that should not be continually dismissed is that a smaller force of attacking units can still slaughter a much larger number of defending units--a number normally disallowed by all other game mechanics. When a force of 5 units attacks a force of 12 or more units and slaughters them (whatever the casualties to the attacking force), that's wrong. Only 5 of those 12 defenders should die, who should then be able to counter-attack the following turn and kill the original 5 attackers.

    Until someone provides an adequate argument to reasonably permit this malfunction, then (with my apologies) I cannot assign any merit to an opposing point of view.

    It is a fact: it violates normal game mechanics, thus that makes it a broken feature.

    And, as I've stated repeatedly in my posts, I have experienced these "contrived" situations repeatedly in my games. They are not unlikely or trivial. They might be rare occurrences on pangaea maps on easy difficulties, or rare for ppl who do not protect their fisheries (bcz fisheries are not important to their overall strategy), but for water maps on higher difficulties, who (bcz it's a water map) depend upon sushi, it can be a substantial problem.

    As to Woody, I will no longer dignify any of his posts with a response.
     
  4. thadian

    thadian Kami of Awakened Dreamers

    Joined:
    Sep 27, 2006
    Messages:
    2,288
    Location:
    Indiana, USA
    i am confused. Are you saying the "patrolling" boats came in and attacked because you attacked a boat defended "illegally" by "patrollers?"
     
  5. ori

    ori Repair Guy Super Moderator

    Joined:
    Dec 17, 2005
    Messages:
    16,561
    Location:
    Baden-Württemberg, Germany
    The problem we face with patrol is that it is not as clear as you make it that the pillager is the attacker. I am still convinced that the is supposed to be the defender. The command you give for the patrol unit is to attack anyone pillaging - if this was implemented this way we would not have to argue about this problem - since of course then in your examples you'd have 5 defender (pillagers) that kill 12 attackers (patrols) - and no problem.
    Now the implementation of this feature is bad. I firmly believe that it was implemented this way because it is easier to have a unit of the player whose turn it currently is (pillager) attack than to make a unit of another player (patrol) attack.

    I believe we can argue forever about this there are two reasonable points of view:
    1) the implementation has the pillager as the attacker - thus he should only have one attack
    2) game documentation has the patrol as the attacker - thus the pillager should be able to defend as often as he survives it
    Now which one is "correct" - I do not know and frankly there is no way to determine this. However if you take position 2) then the actual bugs here are that the pillager gets the tile bonus and the patrol gets the flanking bonus. If you take position 1) then the bug obviously lies in allowing multiple pillage attempts.
    Either way I believe any fix should ensure that it is not overpowering an option that the AI does not use.
    The current situation is this:
    if you have a sea resource you want to guard - you can either
    1) park a couple of ships on it
    or
    2) have a few ships adjacent and give it the patrol function

    1) ensures that any pillager has only one attack - but the ships can only guard one resource
    2) allows a pillager multiple pillaging attempts (I hesitate to say attacks ;) - but at the same time the same number of ships can guard multiple resources AND gain terrain defence bonus even if the resource is not coastal

    If you now use the currently proposed fix - then anyone using number 1) is out of his wits or an AI - since there is no reason to do so - since any patrol will always be more advantageous, basically forcing you to use the patrol function. There are two reasons I oppose this: first and most important - as long as the AI does not use patrol it just benefits the human player - and on sea heavy maps the AI is inept anyways, secondly I believe that this would go against the intended design of the patrol function - but that is a much softer argument I agree :)
     
  6. DanF5771

    DanF5771 Emperor

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Just found another clue that might reveal a piece of the developers' ideas about the Sea Patrol function:
    Code:
    bool CvUnit::canSeaPatrol(const CvPlot* pPlot) const
    {
    	...
    
    	if (!canFight() || [B][COLOR="Red"]isOnlyDefensive[/COLOR][/B]())
    	{
    		return [B][COLOR="Red"]false[/COLOR][/B];
    	}
    	...
    }

    :cry: :cry: :cry:

    ;)
     
  7. ori

    ori Repair Guy Super Moderator

    Joined:
    Dec 17, 2005
    Messages:
    16,561
    Location:
    Baden-Württemberg, Germany
    :hmm:
    if I understand this correctly this means they do not want defense only ships (that do not seem to exist in the unmodded game) or non-fighters (I assume fishing boats) to patrol (is this right? my c++ knowledge is largely derived from reading civ code - so its not too sophisticated ;)).
     
  8. r_rolo1

    r_rolo1 King of myself

    Joined:
    May 19, 2006
    Messages:
    13,818
    Location:
    Lisbon, Portugal
    ^^Me confused ;)

    A defensive only naval unit can't patrol, cool .... :crazyeye:

    I would say that this poits to the idea that it was supposed that the patroling unit would be the attacker.... :p
     
  9. DanF5771

    DanF5771 Emperor

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Yes, this method excludes naval units that are unable to attack from Sea Patrol duty, which would be in line with the ingame docu.

    Still the actual implementation is the other way around and reflects my idea of it--they are supposed to defend the improvements.

    I wanted to check out what the roles are for air patrols. But that is a complete mystery--not even a single line in the combat log. :confused:
     
  10. The Snug

    The Snug The Civ Heretic

    Joined:
    Dec 5, 2003
    Messages:
    954
    Gender:
    Male
    Location:
    Seattle
    Do any of us have any connections with Solver? It'd be nice if we could get him to ask Firaxis concerning this issue...or even if he could throw in his 2 cents.

    Or Bhruic too.
     
  11. r_rolo1

    r_rolo1 King of myself

    Joined:
    May 19, 2006
    Messages:
    13,818
    Location:
    Lisbon, Portugal
    Don't worry, Solver knows of this... just remember that he also has a forum to run ;)
     
  12. The Snug

    The Snug The Civ Heretic

    Joined:
    Dec 5, 2003
    Messages:
    954
    Gender:
    Male
    Location:
    Seattle
    :)



    xxxxxxxchar
     
  13. r_rolo1

    r_rolo1 King of myself

    Joined:
    May 19, 2006
    Messages:
    13,818
    Location:
    Lisbon, Portugal
    I don't think that air patrols combat in the sense that sea and land unit do... perhaps they have a seperated code elsewhere?
     
  14. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    I agree with Ori mostly again.

    We must not take the word of any Firaxians in this manner as the absolute truth. While Firaxis has created a great game, I don't necessarily see their point of view as superior to any of the posters here. When confronted with the barrage promotion bug in BTS 3.17 they said 'remove it'. When confronted with a Glance Screen that wasn't universally considered a work of art, they said 'remove it'. They view this product as finished and thus will take a point of view that results in as little as work as possible. I don't really think that's bad or something from their point of view, but it shouldn't necessarily be our point of view.

    I'm in favour of the following model:

    The patrol ships are the attackers. They can intervene pillage attempts as long as they're alive (just like fighters can). They still get a coastal defence bonus when they're on coastal terrain (weird yes, but I want to give the advantage to the defender which I guess was the intention of making the patrol units de facto defend in BTS 3.17-patrol/pillage-initiated combat). The chance that the patrol ships intervene is directly related to their hitpoints (exactly as is true for fighters and jet fighters, 40 hitpoints = 40% chance of patrol-intervention). If no intervention takes place, then pillaging succeeds.

    Result 1: The pillager cannot retreat from combat because defenders cannot retreat from combat. That removes one weird issue that some players have with the BTS 3.17 patrol mission.
    Result 2: If the pillagers are stronger (by pure unit strength or after bombardment, missile attacks, nuke attacks), then the patrol ships might suicidally attack the pillaging fleet. However the patrol ships are unlikely to intervene when seriously wounded and thus might not suicidally attack in that case. So it would reduce the suicidal behaviour of the ships on patrol duty when faced with a more healthy pillaging fleet.

    Motivation for this model: I like the aerial interception model and it would work fairly well for patrol. It doesn't really mess with other standard game rules. It's tested in slightly different circumstances.

    Problem: I don't even have nearly enough knowledge about programming to implement this model. :crazyeye:
     
  15. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    This thread might be nice to read:

    Air Combat in BTS explained
     
  16. The Snug

    The Snug The Civ Heretic

    Joined:
    Dec 5, 2003
    Messages:
    954
    Gender:
    Male
    Location:
    Seattle
    At any rate, Roland, thanks for your continued (and at least considered) thoughts on the matter.
     
  17. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    You're welcome. :)

    I actually don't think we'll agree since you're looking for a model that limits the number of patrol ships interceptions (against strong opponents) while I don't. We also have a different view on who is the attacker in the patrol interception.

    I don't expect a Firaxian to come along (a very rare occasion) because the issue is not game unbalancing enough. And I actually also don't think Solver will make a decision. He will not want to meddle in an issue which is so hotly debated and has no clear solution. He tends to fix stuff that if clearly bugged or has a universally accepted fix. And that's probably a good thing since otherwise the unofficial patch would soon be accepted by only a tiny group of players.

    However, I believe that DanF5771 already posted (the code for) a fix that you agreed with several pages ago. So why not just use that?
     
  18. The Snug

    The Snug The Civ Heretic

    Joined:
    Dec 5, 2003
    Messages:
    954
    Gender:
    Male
    Location:
    Seattle
    lol. I will, once I figure out what file he altered. :p
     
  19. DanF5771

    DanF5771 Emperor

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    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.

    I have implemented it for a test as follows:
    Code:
    bool CvUnit::pillage()
    ...
    
    if (pPlot->isWater())
    {
        CvUnit* pInterceptor = bestSeaPillageInterceptor(pPlot);
    
        if ((NULL != pInterceptor) [B][COLOR="RoyalBlue"]&& (getCombatOdds(this, pInterceptor)<600)[/COLOR][/B])
        {
            setMadeAttack(false);
    
            attack(pInterceptor->plot(), false);
    
            return false;
        }
    }

    This lets the patrolling ship "decide" to jump in as a defender (getting the plot defense bonus) only if its chance to survive this interception is greater than 40% (the aggressors combat odds < 600). If it "thinks" that this would be a suicide mission, no interception is triggered and the superior aggressor can pillage the improvement.

    I have furthermore disallowed withdrawal of a pillager from an interception combat, thus simulating that the patrol attacks and the pillager cannot escape.
    Code:
    int CvUnit::withdrawalProbability() const
    if (getGroup()->headMissionQueueNode() != NULL)
    {
        if ((getGroup()->headMissionQueueNode()->m_data.eMissionType) == MISSION_PILLAGE)
        {
            return 0;
        }
    }

    So e.g. an Attack Sub will of course still be able to withdraw from a regular attack, but a damaged ASub will be sunk by the patrolling ship during the interception combat when it attempts to pillage the protected improvement.

    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?
     
  20. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    He changed one of the files which are compiled in the CvGameCoreDLL.dll and recompiled (I think). There is a guide in the Creation and Customization forum on how to do this. I did this for the first time a few months ago. Depending on how good you are with computers, the task can be somewhere from almost impossible to extremely easy. It took me some time to figure out how to recompile the CvGameCoreDLL.dll and I barely know anything about programming. I just learned how to do it to make a very basic change in the CvGameCoreDLL.dll (for some minor issue that bugged me). I should learn a bit more about programming so I can make more changes.
     

Share This Page