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

MILITARYAISTRATEGY_NEED_RANGED_EARLY possible bug

Discussion in 'Civ5 - SDK / LUA' started by whoward69, Mar 13, 2016.

  1. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,518
    Location:
    Near Portsmouth, UK
    This looks like a bug in the AI strategy XML to me

    Code:
    <Row>
    	<Type>MILITARYAISTRATEGY_NEED_RANGED_EARLY</Type>
    	<CheckTriggerTurnCount>5</CheckTriggerTurnCount>
    	<NoMinorCivs>true</NoMinorCivs>
    	[B][COLOR="Red"]<TechObsolete>TECH_ARCHERY</TechObsolete>[/COLOR][/B]
    	<UpdateCitySpecializations>true</UpdateCitySpecializations>
    </Row>
    
    MILITARYAISTRATEGY_NEED_RANGED_EARLY maps to IsTestStrategy_NeedRangedDueToEarlySneakAttack in the C++ code and that is commented as
    Code:
    "Need Ranged Early" Player Strategy: If a player is planning a early sneak attack
     we need to make sure that ranged are built since this will block this
    
    so surely the strategy should be switched on at TECH_ARCHERY and not off, ie it should be

    Code:
    <Row>
    	<Type>MILITARYAISTRATEGY_NEED_RANGED_EARLY</Type>
    	<CheckTriggerTurnCount>5</CheckTriggerTurnCount>
    	<NoMinorCivs>true</NoMinorCivs>
    	[COLOR="Green"][B]<TechPrereq>TECH_ARCHERY</TechPrereq>[/B][/COLOR]
    	<UpdateCitySpecializations>true</UpdateCitySpecializations>
    </Row>
    
    Any AI coding strategy experts out there with an opinion
     
  2. Hulfgar

    Hulfgar Emperor

    Joined:
    Mar 31, 2008
    Messages:
    1,797
    Gender:
    Male
    Location:
    France
    I'm not an AI expert but it does look like a bug indeed!
     
  3. ThorHammerz

    ThorHammerz zzz

    Joined:
    Jul 31, 2014
    Messages:
    836
    It does look like a bug.
     
  4. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    I'm not an AI expert either, but perhaps it's used to encourage the AI to research Archery when it needs ranged units...
     
  5. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,518
    Location:
    Near Portsmouth, UK
    I can see what you're getting at, but the AI code to pick the next tech to research is in a completely different code block and can be summarised as "pick a random one from the top two most expensive ones available"

    Been doing some more digging in the C++ code

    IsTestStrategy_NeedRangedDueToEarlySneakAttack determines its outcome based on GetMilitaryAI()->IsUsingStrategy("MILITARYAISTRATEGY_WAR_MOBILIZATION")

    MILITARYAISTRATEGY_WAR_MOBILIZATION switches cities to hammers focus and producing combat units - at the expense of expansion, growth, tile improvement, culture and wonders
    MILITARYAISTRATEGY_NEED_RANGED_EARLY significantly increases the likely hood of producing ranged combat units first (until the MILITARYAISTRATEGY_ENOUGH_RANGED strategy kicks in)

    so I'm pretty sure it's a bug.

    However, given that the AI is pretty much brain-dead, there's probably no point in fixing it!

    Only stumbled across it while making a minimal TC example mod, so will just ignore it now.
     
  6. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    ARE. YOU. SERIOUS?
    :lol::lol:

    Man, sometimes I wonder how long have they worked in the AI?
    Gazebo, whoward, Ilteroi, and others - as MODDERS, not being paid a single nickel - did and do such magnificent job in this aspect of the game that I wouldn't be that much surprised if Fireaxis had an actual monkey trying to get a Shakespeare's play at random and said 'eeh, good enough for our AI'.

    On the other hand, this tells me I'll have pleeeeeenty more work to do with my tech tree, as it has different sections instead of a single path, so, not an entirely face-palm inducing information.


    The top two most expensive ones available... come on. :huh:
     
  7. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,123
    Location:
    Illinois, USA
    I'm pretty sure what was done was meant to make the AI tend to beeline through the tech tree like a human does, and thereby be more competative, especially at higher single-player difficulty-levels. The problem is in that 1st tech choice of the game from the highest-cost-two-available means that 50% of the time a given AI is probably going to beeline along the wrong beeline path as compared to what the Diety-Level Human player would choose, and thereby gurantee that individual AI player is eventually going to become irrelevant for various victory-types. The free AI techs actually exacerbate this issue at higher difficulty levels because the extra free techs given the AI open up additional wrong choices for AI beelining as compared to what the average Diety-Level Human Player would choose to research as the 1st tech chosen in the game.

    [edit]errr.... sorry about the additional thread hijack :sniper:
     
  8. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    The issue here is that 'top two most expensive ones available' isn't a strategy, it's a cop-out.
    I can understand the argument behind the bee-lining, but I can't fathom how that was supposed to be the main strategy; I mean, this departures from the second adjective inherent to 'AI' by such a margin!
    When you leave no room for calculation/thoughts, it stops being an intelligence per se, even an artificial one. This, to me, is exacerbated through the aforementioned problem with MILITARYAISTRATEGY_NEED_RANGED_EARLY.

    I might have to create new tables for the Techs and assign flavor to them, in order to guarantee one Civ isn't getting all Magical researches without upgrading their Keep, or vice-versa! This alone is more strategy than 'generic idea that will always "work".'
     
  9. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,518
    Location:
    Near Portsmouth, UK
    Going way off topic (but I don't mind as the original question is answered) ...

    If you want to control the AI's tech choice (and using DLL-VMC or derivative) use the AiOverrideChooseNextTech event

    Code:
    // Event sent to allow Lua to override the AI's choice of tech (v30)
    //   GameEvents.AiOverrideChooseNextTech.Add(function(iPlayer, bFreeTech) return iChoosenTech end)
    #define MOD_EVENTS_AI_OVERRIDE_TECH                 gCustomMods.isEVENTS_AI_OVERRIDE_TECH()
    
    Edit: And the I in AI implies a lot more than just un-random choices, for a start it needs to a) remember, b) think ahead and c) learn from experience. So that's a "no", "no", and "no" for the CivV "AI" ... the diagnosis is brain-death.
     

Share This Page