Page 3 of 5 FirstFirst 12345 LastLast
Results 41 to 60 of 86

Thread: Campaign AI Project

  1. #41
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    quick query

    from observation where AI factions cease warring when human player also told to do so by Pope, suggests that in M2TW, the AI factions do get papal missions at least.

    here the chances of an ai faction accepting a Papal mission are calculated
    (from M2TW descr_missions.txt)


    Spoiler Alert, click show to read: 

    mission join_crusade
    {
    POPE_MISSION
    image_path_issued pope_mission_issued
    image_path_expired pope_mission_expired
    image_path_success pope_mission_success
    image_path_failed pope_mission_failed
    duration 10
    score_modifier 1.0
    paybacks
    {
    papal_standing -0.4 payback_id pope_major_penalty_only
    papal_standing -0.1 payback_id pope_mod_penalty_only
    papal_standing 0.4 payback_id pope_min_penalty_only
    payback_id pope_min_penalty_min_reward

    }

    leader_pfp_boundary -0.4 ; upper bound for leader required to join
    heir_pfp_boundary -0.1 ; upper bound for heir required to join
    }


    ; chance of ai accepting = ai_accept_base_chance + (faction_standing_to_papacy * ai_accept_fs_modifier) + (global_standing * ai_accept_gs_modifier) + (num_settlements_owned * ai_sett_modifier)
    mission return_papal_settlement ; (NOT SUITABLE FOR VARIANTS) optional mission, duration is ignored, score = 1.0, difficulty = 1.0
    {
    POPE_MISSION
    image_path_issued pope_mission_issued
    image_path_success pope_approval
    image_path_failed pope_mission_failed
    duration 0
    score_modifier 1.0
    paybacks
    {
    papal_standing -0.7 payback_id pope_rome_major_penalty_only
    papal_standing -0.4 payback_id pope_rome_mod_penalty_only
    papal_standing -0.1 payback_id pope_rome_min_penalty_only
    papal_standing 0.1 payback_id pope_rome_min_penalty_min_reward
    papal_standing 0.4 payback_id pope_rome_min_penalty_mod_reward
    payback_id pope_rome_min_penalty_major_reward
    }

    settlement Rome ; the id of the settlement belonging to the papal states
    ai_accept_base_chance 20.0 ; base chance for ai accepting mission
    ai_accept_fs_modifier 80.0 ; ai chance modifier for the papal standing with the ai faction. i.e. the more they like the pope, the greater the chance
    ai_accept_gs_modifier 20.0 ; ai chance modifier for the factions global standing. i.e. the more tructed the faction, the higher chance to give back
    ai_min_settlements 3 ; the minimum number of settlements an ai faction must have to accept
    ai_sett_modifier 5.0 ; ai chance modifier for each settlement an ai faction has
    }




    perhaps the americas don't have those missions as spanish are the only playable catholic faction. Therefore papal missions not included - instead get spanish consulate missions?

  2. #42
    Hister's Avatar Domesticus
    Join Date
    Sep 2006
    Location
    Slovenia
    Posts
    2,233

    Default Re: Campaign AI Project

    GrnEyedDvl, may I suggest that you contact Xeryx or check his CAI - he has done a huge job on CAI and might have something interesting for you...
    PROUD MEMBER OF PAENINSULA ITALICA TEAM

    For M2TW PI forum click here.
    For RTW PI forum click here.

  3. #43
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Quote Originally Posted by Rozanov View Post
    quick query

    from observation where AI factions cease warring when human player also told to do so by Pope, suggests that in M2TW, the AI factions do get papal missions at least.
    The reason they act that way is because there is a special condition related to the Pope that is read by the AI file. It doesnt come directly from the mission being handed out, but rather it sets another variable to true and then that variable is checked. This is the only mission related condition in the AI files, and no way to check any mission status. Other stuff like Crusade/Jihad are hardcoded to the religions, and cannot be modified or assigned to another religion.

    Code:
    has_ceasehostilities="false"   :: does the faction have a cease hostilities mission against the target from the papal faction

    Quote Originally Posted by Hister View Post
    GrnEyedDvl, may I suggest that you contact Xeryx or check his CAI - he has done a huge job on CAI and might have something interesting for you...
    Cool I will take a look soon, thanks.

  4. #44
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Campaign AI Project

    Quote Originally Posted by SigniferOne View Post
    Just so you know, the map has a HUGE impact on how AI performs or not performs. I don't know if CA's map is bug free, and frankly I've found MAJOR path-finding bugs on the Teutonic map so I doubt it. I hear that Pro Deo Et Rege supposedly has a bug-free map, that's what Xeryx has been saying.
    Quoted for truth. Maybe the most important problem here is line of sight, another is the tendency of the AI to go in straight lines and similar things you wouldn't even think of. The LOS problem may be alleviated somewhat by revealing the whole map to the AI at the start of the campaign I believe (EB uses spies everywhere for every faction which are then killed via scripting)

    No thing is everything. Every thing is nothing.

  5. #45

    Default Re: Campaign AI Project

    Quote Originally Posted by alpaca View Post
    The LOS problem may be alleviated somewhat by revealing the whole map to the AI at the start of the campaign I believe (EB uses spies everywhere for every faction which are then killed via scripting)
    That is not needed anymore, you can use reveal_tile instead.

  6. #46
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    have re-read first page of thread and see I seem to have misunderstood what this is about.

    (I think)

    we need to DL the barebones mod and work with that?

    (been buried in stainless steel land so long I'm not up to date with what other mods are out there. - even year old ones.)

    (DL'ing now - see it allows you to make a m2tw mod for kingdoms engine.
    sort of reverse of the retrofit mod?)

    hence the m2tw map but ref to kingdoms mod files.

    (I apologise for being at cross-purposes.)

  7. #47
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Campaign AI Project

    Quote Originally Posted by BozosLiveHere View Post
    That is not needed anymore, you can use reveal_tile instead.
    I think the AI need to see a path to the settlement so unless you want to completely go nuts by using reveal_tile for something like a quarter of a million tiles I'd stick to the spies.

    No thing is everything. Every thing is nothing.

  8. #48
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: Campaign AI Project

    Quote Originally Posted by GrnEyedDvl View Post
    I am trying to get an effective AI without map changes though. The idea here is to drop the AI file into any mod out there and get decent results.
    The problem with this approach is that you won't know, when a malfunction happens, if it happened because of an AI or a map problem. Say an army gets stuck in the middle of a road, and does not move for fifty turns: has it stepped onto a malformed map pixel, or did it merely get stuck in an incorrect AI decision loop? You won't know.
    Last edited by SigniferOne; September 28, 2008 at 04:55 PM.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  9. #49
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Agreed, but I am certainly not going to rebuild the vanilla map.

  10. #50
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: Campaign AI Project

    That's why I pointed you to Pro Deo Et Rege. Xeryx knows his campaign AI stuff inside and out, like backward and forward. He's said that he has adopted the PDER for his platform as it seems to be remarkably lacking in bugs.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  11. #51
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    Did an experiment on the barebones mod to see if adding roads solved the problem. (note used the descr_campaign_ai file from barebones.)

    Will try again with the latest descr_campaign_ai file.

    Spoiler Alert, click show to read: 


    Do roads help the AI controlled factions reach their targets?
    --------------------------------------------------------------------------------------

    Hypothesis
    ----------------

    Adding basic roads to rebel regions at the start of the campaign should help the AI controlled factions in the early stages of an early era grand campaign to attack more targets or be more succesful in attacking those it did target.

    Apparatus.
    ----------------

    The basic GED Barebones mod with one modification: the descr_strat.txt file was amended so that all rebel settlements (town or castle) with a population of large_town or above was given either roads or c_roads as appropriate. Game was played on M/M difficulty.

    Method
    -----------

    I took the role of England in this test. Every turn I responded with the minimum positive response to foreign envoys. No building was undertaken. The field armies were sent to Nottingham and Caen. No missions were undertaken, and neither English envoy was moved. Toggle_fow was done and the entire map monitored.

    Each turn was then played and the movements of the AI noted where this resulted in an attack on a rebel held settlement, or siege. The outcomes of these attacks was also noted. This was done for 14 turns.

    Results
    -----------

    NB Due to the method used the occasional attack was missed due to writing down at the same as the attack was undertaken. Also the game engine calculates some attacks between the end of movement and the start of the player's turn. The entire map was scrutinised each turn to see if any attacks had been missed.

    To save typing the following abbreviations are used: BS - besiged; ATT - attacked; WD withdrew from; OS - outside

    Fr - France; HRE - HRE; Pol - Poland; Sic - Sicily; Port; Egt - Egypt; Den - Denmark; Ven - Venice; Nov - Novgorod; Mil - Milan; Byz - Byzantines; Turk - Turks;
    Hun - Hungary;

    Turn 1: Fr BS Dijon
    HRE BS Hamburg
    Pol BS Thorn

    Turn 2: Fr WD Dijon
    HRE WD Hamburg
    Sic land OS Tunis
    Port BS Zaragoza
    Pol WD Thorn

    Turn 3: Egt BS Jerusalem
    Den BS Hamburg
    Port WD Zaragoza
    Pol BS Thorn
    Sic BS Tunis

    Turn 4: Fr BS Dijon
    Ven ATT Zagreb - CAPTURE
    Sic WD Tunis (Sic Gen dies)
    Nov BS Helsinki
    Den WD Hamburg
    Port BS Zaragoza

    Turn 5: Fr WD Dijon
    Mil BS Dijon
    Byz BS Sofia
    Nov WD Helsinki
    Egt WD Jerusalem
    Port WD Zaragoza
    Pol WD Thorn
    Nov BS Moscow

    Turn 6: HRE BS Magdeburg
    Turk BS Trebizond
    Den BS Hamburg
    Hun attack Bucharest - FAIL
    Mil CAPTURE Dijon
    Nov CAPTURE Moscow

    Turn 7: HRE CAPTURE Magdeburg
    Turk WD Trebizond
    Pol WD Thorn

    Turn 8: Egt BS Jerusalem
    Den CAPTURE Hamburg

    Turn 9: Spain BS Zaragoza
    Egt WD Jerusalem

    Turn 10: Spain CAPTURE Zaragoza
    Byg WD Sofia
    Byz ATT Durazzo - CAPTURE

    Turn 11: Egt BS Jerusalem

    Turn 12: HRE ATT Breslau - CAPTURE
    Sic BS Tunis
    Egt WD Jerusalem
    Egt BS Jerusalem
    Egt ATT Jedda - CAPTURE

    Turn 13:

    Turn 14: Egt CAPTURE Jerusalem
    Pol BS Thorn
    Turk BS Adana

    The following rebel settlements with roads were attacked: Jerusalem; Hamburg.
    The following rebel settlements with roads were not attacked: Acre; Antioch; Antwerp; Baghdad; Bern; Bruges; Bordeaux; Damascus; Edessa; Kiev; Prague; Timbuktu.

    The first 2 settlements with roads (Jerusalem and Hamburg) are those which the AI usually attacks first anyway.
    The AI usually avoids all or nearly all of the others in the first 14 or so turns.

    Conclusion
    ----------------

    Assuming this to be a representative experiment (it could be re-run by others to check) then there is no evidence from the results that indicates that on this particular map that adding roads makes any difference whatsoever to the ability of the AI to attack settlements in the early stages of the game. The targets appear to be chosen for other reasons. It is is noted that all of the unattacked settlements were of large_town status or above. It is quite possible therefore that at this stage of the game the AI is deliberately targetting those settlements with smaller garrisons. The inital hypothesis to be checked is therefore abandoned.

    Future experiments:
    -----------------------------

    The final line of the conclusion therefore suggests that the next experiment should take the form of using the revised map (with added roads) but with equalised garrisons, so that every rebel settlement has the same size garrison to see if this makes any difference to which settlements are targetted.

    Another experiment could be undertaken to see if the size of attacking armies is a decisive factor in the success rate for attacks, perhaps by changing the ratio of attacker v defender for an attack to be attempted, thereby encouraging the formation of larger attacking armies.

    R.

    Last edited by Gorrrrrn; September 30, 2008 at 10:35 AM. Reason: clarification

  12. #52
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: Campaign AI Project

    GED, can you try something out: I've heard that the AI does not disband its units correctly. Is that true?

    Imagine the possibilities if disbanding worked correctly -- you could create "militia" units which cost 10 to recruit but 1000 to upkeep, so the faction would raise them in a blink of an eye and then try to disband them as quickly as the threat becomes over.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  13. #53

    Default Re: Campaign AI Project

    Quote Originally Posted by Rozanov View Post
    Adding basic roads to rebel regions at the start of the campaign should help the AI controlled factions in the early stages of an early era grand campaign to attack more targets or be more succesful in attacking those it did target.
    What about adding roads to all regions, that way the AI agents etc can move out of their own regions quicker. If there is no AI sight bonus in play then in some regions the AI might not 'see' the 'path' into the rebel regions...

  14. #54
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Re: Campaign AI Project

    Quote Originally Posted by SigniferOne View Post
    GED, can you try something out: I've heard that the AI does not disband its units correctly. Is that true?
    I have heard that, and also heard that it doesnt merge damaged units properly, but its not something I can confirm.

    I agree that would certainly be useful. I wont have much time to work on this during the week, I have a lot of stuff going on, but I will be trying out some new stuff over the weekend probably.

    Eothese, I agree roads added to all regions rather than rebel would be a better test.

  15. #55
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    Roads - didn't add all roads as the AI factions usually add their own roads within the first few turns anyway. (saves me typing)

    Secondly it gave a useful comparison between those rebel settlements with roads and those without.

    Thirdly not all regions are developed enough to have roads and I didn't want to have to go through and raise the level of settlements so they could all have them. (Level 0 settlements/castles don't get roads until they reach level 1)

    So I gave roads to those rebel regions at the same level of development that had roads as the faction controlled settlements at the start of the game (minimum large_town in this map.)

    Observing what the AI factions did, the Turks, for example, walked past Edessa (had road but large garrison) and usually attacked places such as Trebizond - no road but smaller garrison.

    The French ignored Bordeaux (road but large garrison) but eventually walked over the mountains to attack Zaragoza (no roads) once the garrison had been reduced by 2 Portuguese attacks.) Likewise Milan ignored Bern, but pounces on Dijon after the French have reduced the garrison.

    SO my working hypothesis at this stage is that it is the relative strength of garrisons that is a major factor in determining which places get attacked in the early stage of the game - with the exception of key strategic places such as Jerusalem and Hamburg. (Egypt keeps attacking until it captures it for example, irrespective of the size of garrison (but always with an equal (or higher) number of units compared to the garrison.) Here the value of the settlement out-weighs the garrison size.)

    Hopefully once we have a definitive list of regions by number one can check that in the LTGD log.

    I did the LTGD trace on the first 14 turns - generates huge amount of data.

    Then tried to work out what the regions were referred to in the invasion decisions. I tried using the descr_regions_and _settlement_name_ lookup file as that lists everything very neatly and numbered the regions from 1 to 119 (approx). Doesn't work - some naval invasions are for land-locked regions. Tried 0 to 118 - still doesn't work, some of the numbers look 1 or 2 out, but inconsistently. Is there a definitive list with the correct numbers of regions please?

    Scrolling through the pages (over 5700 according to word for windows) (no chance of printing that lot out!!) I notice that the HRE seem to get an extra "go" each turn and that the order of evaluation changes. Is there a rationale for that?

    I presume there are other traces that can be run to determine building, recruiting and agent behaviour?

    (Did another run through with latest descr_camapign_ai file: observations - finally caught Milan invading and failng to take Flornce in a naval invasion Milan; once again I missed Novogord capturing Moscow - I've never seen them besiege it in 5 short campaigns yet they always capture it; Novgorod stack up a huge army west of the city itself, no idea where they're going with that lot; France seems paralysed after failing to take Dijon, they have a lot of options but
    do little (I still suspect the size of the English garrison in Caen is a factor there.)

    The random factor plays a huge part in the early stages - twice Sicily take Tunis early on, and twice I've seen them fail and the general dies; If the Poles capture Thorn quickly the prosper, if not they get stuck; armies turning rebel due to lack of general seem common (either that or large numbers of rebel armies get spawned -either way some factions spend a lot of effort in controlling them in some campaigns which prevents them from expanding so quickly; Hungary nearly always builds up a big army nw of Sofia but does nothing with it (by turn 14/15); Scotland just sits there; If the danesa can capture Hamburg quickly and aren't too troubled with rebel armies they can take Magedburg and Stettin; other times HRE can capture Magdeburg.)

    ---

    (Damaged units - from observation only in stainless steel (i have no way currently of testing this) - the AI can rebuild units if it has enough money and if it can't do anything else with the money it has. The financial allocation seems to be: start with top settlement in list, if no building being undertaken build best building with money available, continue down list of settlements until no buildings can be started with money available. Then check for buildings to repair. Then build units - again best affordable from the top down. Then agents (? - no idea actually where they fit in) and then rebuild any units with any spare cash from top settlement down. Most damaged units are in the latest settlement captured, which has the least priority as it is the last in the list (and often has damaged buildings.) So it sometimes happens that units never get rebuilt as there isn't the cash to do it. (And, of course, military buildings tend to be the ones damaged so no recruiting can be done until they are fixed and the units may not be recruitable there anyway.) The AI doesn't seem able to take units from one settlement and return them to a settlement where they can be retrained which is what many human players tend to do. (Might help if more units were recruitable in both castles and towns?)

    (Alternatively it evauates each settlement in turn for new buildings, repairs, new units, agents, repair units etc. This could easily be established with requisite trace. Either way rebuilding units is the last priority in the building queue so often doesn't get done.)

    (I've even noticed that if I let the AI spend cash for the faction that I'm playing that units will be rebuilt without queueing them if possible (ie if they are in a region they can be recruited in and the settlement is being auto-managed.) Priority seems always to build new units from the top settlements (not such a bad idea as they tend to be the biggest and most developed and so most capable of building good units.)

  16. #56
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    OK further to damaged units and AI repairing damaged buildings:

    Spoiler Alert, click show to read: 


    Some more observations on the Campaign AI
    -----------------------------------------------------------------

    Intrigued by the failure of the HRE to expand very far, and also by the priorities the AI assigns to settlements in the game, I played 30 turns as HRE in Barebones scenario. The AI was given total control of building and recruitment. (NB with auto-managing no agents are recruited or armies moved. So human player has to do these if they want them to happen.) Generally the AI adopted a balanced tax rate, except after capturing settlements, when it adopted a military stance.

    I responded positively to all diplomatic contacts, but initiated none. All rebel armies were fought by the nearest garrison. Because the AI did not recruit any agents, I recruited priests, assassins etc to counter heretics. I did not declare war on any other faction (except when I joined a Crusade), and none declared war on me.

    After battles damaged units were moved to where they could be repaired (if buildings had been built.) (NB no units were ever added to the recruitment queue or buildings added to the build or repair queues.)

    Certain aggressive military adventures were attempted with the forces the AI provided:
    Siege of Antwerp (T9) - BSing army attacked by defenders first turn and defeated by them - attackers retreated.
    Siege of Prague (T20) - Successful (T24)
    Join crusade on Cairo called (T28) (Actually joined a few turns later.)

    (After T30 played another 40 turns to see what happens but didn't keep record of building)
    (Joined another Crusade, again on Cairo; captured Antwerp, Florence, Bern all with the AI determining the tax rate and which units to build. Overall the AI does a very good job of managing the economy, even if its decision making on unit production is a little wayward at times. It is however very rigid in certain aspects, which results in newly captured settlements often failing to build new units or repair buildings quickly, they have to keep their position in the queues. Also found public order problematic in Bologna (probably resents having German govenor?)

    As the overall faction stance is Balanced Smith, this should be balanced regarded production - with biases towards growth, taxable income, trade level bonuses (roads), walls and xp bonus buildings; whereas unit production should be exactly even, with no bias towards any particular type of unit. (This from CavalryCmdr's excellent essay on the subject) However production can be biased by strategic considerations, such as I'm under threat from an enemy so build defenders, our enemy has many cavalry so build more spearmen. Apparently.

    Sadly CavalryCmdr does not seem to have delved further into working out the AI's production priorities in any detail (AFAIK.) So we have to rely on a certain amount of deduction with the caveat that this needs confirming from proper traces of AI decision making.

    I have appended an Excel compatible spreadsheet showing what was built on which turns for HRE in the first 30 turns.

    From this we can see that, as long as the AI has sufficient money it keeps building buildings. The AI seems to like a certain float for "discretionary expenditure" and for expenditure that isn't accounted for in the initial decision making phase for the human player (which presumably AI factions don't need so they can spend - it merely allows some cash for the human player to spend on agents, non-queued building, extra units etc. Given it's more economical not to duplicate code, one can guess that every faction has a slot if_player_human for this section that gets ignored otherwise.)

    (NB although most buildings are "queued", the AI is quite capable of using some of the "discretionary money" to build single turn buildings such as dirt roads, small chapels, between the human player pressing end turn and the beginnings of a new turn. The turn a building is completed the queue is empty in that settlement but the AI regards it as occupied when deciding it's main spend. (The human player can add a building here if there is enough cash, but with the exception of single turn items, the AI usually waits another turn before starting another building for that settlement.)

    The order for decision making is the order settlements are displayed in the lists on screen, which means that the settlements at the top of the list will tend to get the best buildings, but, by not starting building for multi-turn buildings until after the turn a building is completed, there is some scope for settlements further down the list to get new buildings, but that diminishes as the number of settlements increases (with the limiting factor that in later game stages the AI may not have enough money to build expensive buildings in the top settlements and so may build lower down the list until it has enough spare money (which it rarely has.) Which building gets built is down to several factors, and amongst those is likely to be a randomising factor, so the order of building will differ between settlements. Also with different start times (in turns) circumstances may change so priorities may also change.

    One priority does seem to be true however. Wall upgrades are prioritised - presumably as they give happiness bonus and enable better units to be built and so score more highly than other buildings? In every instance once any existing buildings were completed the wall upgrades were started the next turn there was sufficient money. Although outside the time limit for detailed comment, by turn 70 Vienna had managed to get a merchant bank built! (not bad for early era! )

    Regarding newly captured settlements a lot depends on the money obtained by sacking and the number of settlements without queued buildings. If there's a lot of money and nearly all other settlements are already building, then repairs may occur very promptly - having captured Cairo, for example, all damaged buildings were repaired within 2 turns! However I also noticed that the AI often builds new buildings before spending money on repairs. Prague got a new Grain Exchange and a Ballista Maker before the walls were repaired. From this one can deduce (with usual caveats!) that there is some algorithm that assigns numerical values to each building depending on what the build priorities are and (as in the invade decisons, the game engine works out the options and goes with whatever scores the highest, within the remaining budget.)

    (note on modding and adding new buildings - these numerical values have to related to what the game engine already understands, so buildings that add happiness, allow better units to be built, increase public order; add to religion conversion etc can all be factored in, but it's unlikely to pick up on those which add traits to agents and generals?)

    -----

    Moving onto what units the game engine builds.

    This is much more difficult to work out from observation as the human player inevitably has an input in what units get used and as the game progresses the interaction with other factions will also have be factored in. All one can say is that in this case the human player was only at war with one faction - Egypt (and no units were built in Cairo on both occasions it was occupied) and did not belong to any alliances, then the test case is representative of a fairly neutral set of circumstances. What the AI would build if it was at war with neighbours and involved in alliances I shall leave to others to discover.

    The first striking observation is that for the first 8 turns the AI did not recruit any units, despite being able to recruit at least town guard and peasants. Evidently it saw no need to bother with such units. After that the majority of units were those available at the main castle of Staufen: 7 Mailed Knights, 1 Sgt spearmen, 2 Armoured Sgts, 2 Peasant x-bows. Innsbruck provided 3 Mailed Knights and 4 Mtd Sgts. Bologna contributed 2 Cogs and 2 Merchant Cavalry Militia (once merchant guild built.) None of the towns built any spearmen and Prague built 1 unit of Town Guard, before it started spamming ballisas and (later) catapults. All the spearmen and peasant archers were those the HRE started with, with me shifting them to towns and castles, respectively, to be rebuilt if necessary.

    Now it would dangerous to generalise but here it appears that the game engine is biased towards high value units against low value ones, preferring not to build any low value ones rather than spend money on peasant and militia units. This is probably due, in part, because I didn't make many offensive moves and the only factions we were at war with were Egypt and Rebels and so there was no need to build more defensive units. However after building many cavalry units in Staufen the AI switched to heavy spears and x-bows presumably to achieve some sort of balance. (Some time after the 30 turns Frankfurt got the Teutonic Knghts order building and built 3 units of mounted Teutonic Knights, but I don't recall any towns building any spears in all 70 turns, although xbow militia later appeared in a couple of towns.)

    Regarding repairing units.

    These the AI handles quite efficiently, provided the units are inside a settlement that can rebuild them. This is a very important consideration as many of the units a faction starts with in Barebones (not to mention M2TW , Kingdoms scenarios and other mods (including Stainless Steel)) cannot be recruited or repaired as the buildings simply don't exist to build them at the start of the game. (This is one of my bugbears - IMHO only those units that can be recruited should appear at the start up of the game - if that means upgrading settlements to allow this, so be it.) Also some town units are in castles and castle units are in towns. As the AI never (AFAIK!) moves units to rebuild them deliberately (some might end up in the relevant settlements by accident) any of the units in the "wrong" type of settlement will never able to be rebuilt. (Either they should be assigned to the correct type of settlement or both types of settlement should be able to recruit a range of basic units.)

    Anyway once the relevant buildings had been built, those units in the "correct" type of settlement were repaired as quickly as the recruitment slots would allow. Upgrading once leather tanners had been built also worked very smoothly. Every unit got queued up and upgraded. (NB as there were less than 9 in Frankfurt at the time it remains to be seen if the AI remembers to check those it couldn't queue up as soon as the building is built.) It should be noted that only 1 leather tanner building was built in 30 turns, suggesting a priority in building better units rather than upgrading existing units, and that the leather tanner is built more because the AI can afford it?

    Regarding priorities, contrary what I believed previously, the AI attended to repairing and upgrading units before building new units, provided it was able to do so, although is also capable of doing both at the same time if the number of recruitment slots allows.

    ------

    Conclusions

    Firstly we have to assume that the decisions the AI makes for the human player are similar (if not identical) to those it makes for factions under its own control. With the obvious exception that the game expects the human player to take control of agent recruiting and army movements and responses to "missions".

    The AI appears competent at running the economy generally speaking. Most problems I had with balancing the books (and in 70 turns it was never more than 300 fl in the red) were down to interventions I made. Public order is capable of a degree of control - I noticed settlements changing from blue or red face to yellow after the end of the player turn suggesting a change in tax regime but it can be vulnerable if too many of the garrison leave and fail to return, or a good govenor dies - it's down to the human player to shift govenors around. So this cannot replicate the AI faction behaviour.

    Regarding new buildings, with a balanced stance the AI built a range of buildings, generally starting with economic buildings but switching to military later on, with a scattering of religious and public order buildings. If this is typical of AI behaviour for the factions it controls, then one cannot expect the early turns to be very military oriented, and so one shouldn't expect much military activity, apart from the units a faction starts the game with. Given the lack of buildings to recruit from in the early stages of the game and the difficulty of repairing units, the first 10 turns or more are unlikely to see much sustained activity. It also seems that certain settlements are assigned a role for unit recruitment, a specialisation. For example the only settlement to produce ballistas and (later) catapults was Prague, although others could have built them.

    There seems a bias towards recruiting the best units available and against recruiting lesser ones. This can lead to unbalanced armies taking the field or lop-sided garrisons. The lack of basic spear miltia recruitment is certainly a drawback, as is the lack of basic missile units. It is, of course, possible this is due to the lack of nearby enemies to threaten settlements and thereby provoke more defensive unit production.

    The only problems regarding repairing damaged settlements appear to be the order a settlement is in in the main list; the lack (sometimes) of money; and the AI preference for building a couple of new buildings before it repairs existing ones. There is undoubtedly an algorithm that controls this by assigning values to all possible building it can build or repair. So it may calculate that there is more to be gained from building new buildings than repairing existing ones.

    Repairing units is constrained only by the fact that many units are in (or end up in) settlements that cannot repair them due to lack of suitable buildings either because the building doesn't exist yet, being the "wrong" type of unit for settlement or possible lack of money. Generally the AI will try and repair and upgrade units before it builds new units if it is possible.

    Attachment 20455
    Last edited by Gorrrrrn; October 03, 2008 at 11:58 AM. Reason: added zip file of spreadsheet

  17. #57

    Default Re: Campaign AI Project

    Rozanov what happens if you give the AI the highest level military and economic buildings for their settlement level at the start of the game (add them into the descr_strat)? Do they become militarily active earlier on?
    Morning Sun (adds Korea and China to the Shogun 2 map)
    http://www.twcenter.net/forums/forum...28-Morning-Sun

    Expanded Japan mod (97 new regions and 101 new factions)
    http://www.twcenter.net/forums/showt...ew-factions%29

    How to split a region in TWS2
    http://www.twcenter.net/forums/showt...split-a-region

    Eras Total Conquest 2.3 (12 campaigns from 970-1547)

  18. #58
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007
    Location
    here
    Posts
    5,546

    Default Re: Campaign AI Project

    uanime5

    good question.

    and one that I may attempt to answer when I get time to amend the relevant file.

    All I can say is that the settlement level and buildings for HRE prevented the creation of decent units for many turns (no criticism of the mod BTW.) We can't expect the CAI to deliver the necessary result (AI blitzing in early turns) unless they are given the troops to do the job. (I tried besiegeing Antwerp with the HRE main field army and got trounced by the garrison when it sallied forth on auto-resolve.) Improving the buildings and allowing a wider range of units to be built in both types of buildings might allow the AI to rebuild its battered units and build better new ones but with the current set-up there's no chance of it doing so in the early game.

    Whilst the project of makiing a better CAI is very worthwhile, I can't help thinking that every mod will need to have its CAI tweaked to fit in with its particular map, units, starting positions etc.

    Regarding the Barebones mod, given the starting positions of settlements it might be better to remove the field army/ies of the human player to prevent the human player from blitzing, rather than trying to modify the CAI to compensate. Currently the settlements and castles with decent size garrisons will defeat most AI attacks and so only the smaller settlements are likely to be attacked and taken by the AI (and when they do it will take a long time before they can rebuild the units in them.)

    What I couldn't test was the extent to which the AI moves units around between settlements as that is human control when you play a faction, or what offensive actions it takes.

    What this project can help with is helping people, like myself, who know very little about the game mechanics, get a start at undertsanding them. Also those who know more can use it to try out new ideas perhaps.

    We also need to take into account the dynamic nature of the game, creating a CAI that works well for the first few turns may not be the best CAI for later in the game?

  19. #59
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Campaign AI Project

    This may look like necro but it's not I think. I'd say it's a "back to the roots". This thread has some vital information and links.
    Quote Originally Posted by Gorrrrrn View Post
    We also need to take into account the dynamic nature of the game, creating a CAI that works well for the first few turns may not be the best CAI for later in the game?
    In my studies with AI I came to the same idea and seems that we got no AI that consider this thing. Every faction has at least 2 stages in it's "life" - 1) initial expansion mostly for account of rebels 2) struggle with other factions to accomplish win conditions. These goals require different types of CAI (if we want to add real diplomacy and even geopolitics ingame). I think this things may be done with standard methods of descr_campaign_ai_db and at this time I'm working on it for my Westeros mod.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  20. #60
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Campaign AI Project

    Have you seen that target_faction parameter also has min/max entry? Seems that it was never used in AI coding. And for early/mid turns in campaign it could be useful.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

Page 3 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •