Results 1 to 30 of 121

Thread: Game AI stuff (1.5)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Game AI stuff (1.5)

    a type of glitch, a minor addendum and a major breakthrough

    1) a type of glitch

    generally if the AI is stuck it can be hard to spot as often it is just one stack among many but then there's the other kind

    Click image for larger version. 

Name:	glitch.jpg 
Views:	876 
Size:	384.3 KB 
ID:	20518

    this can happen when
    a) a faction has only one potential adjacent land target and the army assigned to it is stuck
    b) a faction has no potential land targets and the a naval landing has glitched
    c) a faction temporarily has no adjacent land targets cos it's at peace with all it's neighbors - this generally only happens briefly after defeating one enemy faction and before starting a new war with a neighbor

    in this case it was (c) - Macedon has just defeated Greece and was at peace with all its other neighbors

    #

    2) a minor addendum

    the fastest way to clear most path-finding glitches is to check the settlement-to-settlement path between adjacent regions looking for any clipping issues however

    vanilla Macedon: army in Larissa moves out to city "waiting spot" (usually the tile SW of settlement unless it's blocked) and waits, getting extra units from Larissa each turn and getting the Captain promoted to general (the AI will often promote a captain of a stack that has been assigned a target settlement)

    261BC

    Click image for larger version. 

Name:	stuck01.jpg 
Views:	890 
Size:	371.7 KB 
ID:	20519

    and waits 254BC

    Click image for larger version. 

Name:	stuck02.jpg 
Views:	827 
Size:	362.6 KB 
ID:	20520

    and waits 226BC

    Click image for larger version. 

Name:	stuck03.jpg 
Views:	837 
Size:	370.9 KB 
ID:	20521

    eventually (209BC) another faction takes the target settlement (Athens)

    Click image for larger version. 

Name:	stuck04.jpg 
Views:	832 
Size:	377.3 KB 
ID:	20522

    and the stack moves

    Click image for larger version. 

Name:	stuck05.jpg 
Views:	840 
Size:	385.5 KB 
ID:	20523

    but after 100+ turns of not expanding and paying the upkeep for a full stack that isn't doing anything it's a bit late

    Click image for larger version. 

Name:	stuck06.jpg 
Views:	817 
Size:	373.9 KB 
ID:	20524

    #

    Solution

    if you look at the fastest path from Larissa to Athens it seems okay

    Click image for larger version. 

Name:	stuck_sol01.jpg 
Views:	867 
Size:	366.7 KB 
ID:	20525

    and to be thorough the fastest path from Larissa's waiting spot to Athens also

    Click image for larger version. 

Name:	stuck_sol02.jpg 
Views:	904 
Size:	370.1 KB 
ID:	20526

    but if you move the mouse around the tiles adjacent to the target settlement rather than the settlement itself the path clips the Corinth region

    Click image for larger version. 

Name:	stuck_sol03.jpg 
Views:	847 
Size:	377.6 KB 
ID:	20527

    also, just to be thorough again, on the assumption the AI doesn't calc settlement to settlement but 1) start tile to fastest path to a passable tile in the target region and then 2) from that tile to the target settlement then check that too - which clips also if for whatever reason the path finding chooses to go that way around the mountain

    Click image for larger version. 

Name:	stuck_sol04.jpg 
Views:	850 
Size:	357.6 KB 
ID:	20501

    on the assumption the path-finding does go that way for some reason it is easily fixed by giving the tile it clips through to the Athens region - which seems to work

    #

    so the expanded sequence is

    1) check the fastest path settlement-to-settlement doesn't clip
    2) check the fastest path from the start settlement's waiting spot to the target settlement doesn't clip
    3) check the fastest paths to tiles adjacent to the target settlement don't clip
    4) lastly check the fastest path from the start settlement to a passable tile in the target region is not different from the fastest path overall

    #

    example of last point

    the fastest path from Narbo to Lugdunum seems okay

    Click image for larger version. 

Name:	umm01.jpg 
Views:	856 
Size:	411.2 KB 
ID:	20528

    (actually it's not as although the diagonal from Narbo region to Lug region doesn't clip, the underlying orthogonal path can only go either right and up or up and right and the latter is blocked by the mountain tile so the orthogonal path clips the Massilia region - however it can easily be fixed by removing that corner tile from Massilia)

    however the fastest path from Narbo to the nearest passable tile in Lugdunensis is like this

    Click image for larger version. 

Name:	umm02.jpg 
Views:	881 
Size:	393.8 KB 
ID:	20529

    and the fastest path from that tile within Lugdunensis region to Lugdunum clips back into Narbo region.
    Last edited by nikolai1962; 01-28-2018 at 23:35.
    It's not a map.

    Member thankful for this post:



  2. #2

    Default Re: Game AI stuff (1.5)

    split into two posts as too many attachments

    #

    3) a major breakthrough

    path finding problems are mostly in three categories
    1) problems at the very start of the game which i could never figure out till now
    2) problems that recur consistently during early expansion
    3) problems that mostly occur later in the game and more randomly depending on the ebb and flow of expansion

    I'd given up on what caused (1), fixed most of (2) and was finishing off (3) and just realized how to fix (1).

    example Thrace faction, Sautes

    at the beginning of the game before factions are at war with other factions they target nearby rebel regions so Sautes ought to target Byzantium

    270BC

    Click image for larger version. 

Name:	sautes01.jpg 
Views:	849 
Size:	327.8 KB 
ID:	20530

    268BC

    Click image for larger version. 

Name:	sautes02.jpg 
Views:	850 
Size:	328.3 KB 
ID:	20531

    265BC Sautes has died but the now Captain led army still doesn't move as Macedon heads for Byzantium

    Click image for larger version. 

Name:	sautes03.jpg 
Views:	837 
Size:	343.0 KB 
ID:	20532

    260BC if Macedon had succeeded the army would have been given new orders and moved off but they didn't so it's still stuck

    Click image for larger version. 

Name:	sautes04.jpg 
Views:	830 
Size:	343.3 KB 
ID:	20533

    there's a bunch of these in vanilla among the factions e.g. Vindex for the Gauls, Arsaces for Parthia etc and glitches like this right at the start of the game have a compound effect on a faction's expansion.

    there are three ways armies like this become unstuck during the game:

    1) another faction takes the settlement so the stuck army gets new orders
    2) the distance between the stuck army and the settlement comes within one turn of movement (roads are built, general gets a movement trait etc)
    3) occasionally attacking or being attacked by a nearby rebel spawn

    you can "fix" these problem by making the path one turn only through one or more of: increasing base movement points, giving the general a movement trait, building roads in advance, moving the general closer, moving the settlement etc but this is more like over-riding the problem than figuring it out and fixing it.

    for example Sautes with base movement points set to the vanilla 80

    Click image for larger version. 

Name:	sautes05.jpg 
Views:	823 
Size:	324.4 KB 
ID:	20534

    with base movement points increased to 120 he is within one turn of Byzantium

    Click image for larger version. 

Name:	sautes06.jpg 
Views:	822 
Size:	330.7 KB 
ID:	20535

    and attacks first turn

    Click image for larger version. 

Name:	sautes07.jpg 
Views:	817 
Size:	312.9 KB 
ID:	20536

    #

    The clue i missed is the rare occasions when a stuck army moves to attack nearby rebels.

    the bug is an army assigned to attack an adjacent rebel settlement in the first turn before it has moved is not fully initialized in some way and only becomes so after its first move.
    so counter-intuitively an actual fix is to move the army further away - specifically to a region that isn't adjacent to the the target settlement so the army has to do region-to-region movement first, in this case reduce MP back to 80 and move Sautes into the other Thrace faction region

    Click image for larger version. 

Name:	sautes08.jpg 
Views:	861 
Size:	330.3 KB 
ID:	20537

    and he quite happily find his way to Byzantium over the next few turns

    Click image for larger version. 

Name:	sautes09.jpg 
Views:	836 
Size:	300.0 KB 
ID:	20538

    Click image for larger version. 

Name:	sautes10.jpg 
Views:	835 
Size:	321.8 KB 
ID:	20539

    Click image for larger version. 

Name:	sautes11.jpg 
Views:	838 
Size:	322.1 KB 
ID:	20540

    update: with further testing it turns out the army doesn't have to be in another region just > 2 turns move away from the target settlement so < 1 or > 2 turns away is okay but if both > 1 and < 2 turns away it gets stuck. useful to know as any time you change MP some armies may become stuck and some unstuck.
    #

    there are a bunch of these among the various factions e.g Vindex in his original spot would never move unless you made Massilia within one turn of movement

    Click image for larger version. 

Name:	sautes16.jpg 
Views:	828 
Size:	330.6 KB 
ID:	20541

    but if you move him just over the region border into Aquitaine

    Click image for larger version. 

Name:	sautes12.jpg 
Views:	825 
Size:	339.3 KB 
ID:	20542

    he'll quite happily find his path to Massilia

    Click image for larger version. 

Name:	sautes13.jpg 
Views:	811 
Size:	323.2 KB 
ID:	20543

    Click image for larger version. 

Name:	sautes14.jpg 
Views:	829 
Size:	355.7 KB 
ID:	20544

    Click image for larger version. 

Name:	sautes15.jpg 
Views:	840 
Size:	316.9 KB 
ID:	20545

    update: actually only 3 in the vanilla game: Vindex, Sautes and Arsaces, as the others are > 2 turns away from their targets.
    #

    took me 10+ years but finally figured it out.
    Last edited by nikolai1962; 01-29-2018 at 05:46.
    It's not a map.

    Members thankful for this post (2):



  3. #3
    Senior Member Senior Member ReluctantSamurai's Avatar
    Join Date
    Feb 2008
    Location
    USA
    Posts
    2,483

    Default Re: Game AI stuff (1.5)

    the bug is an army assigned to attack an adjacent rebel settlement in the first turn before it has moved is not fully initialized in some way and only becomes so after its first move
    with further testing it turns out the army doesn't have to be in another region just > 2 turns move away from the target settlement so < 1 or > 2 turns away is okay but if both > 1 and < 2 turns away it gets stuck
    Some weird internal thing? Does the same thing happen with a faction at war with another faction, rather than rebels?

    but after 100+ turns of not expanding and paying the upkeep for a full stack that isn't doing anything it's a bit late
    Seen that scenario played out repeatedly

    took me 10+ years but finally figured it out
    Sometimes, the solution isn't in a straight line...
    High Plains Drifter

  4. #4

    Default Re: Game AI stuff (1.5)

    Quote Originally Posted by ReluctantSamurai View Post
    Some weird internal thing?
    Yes, I've noticed something like this before with armies moving to a target and getting stuck > 1 but < 2 turns away. Just a guess but I think there are two bits of path-finding code, long-distance and short-distance and the game switches from one to the other when an army is "in range." However my guess is the game was originally developed with higher base MP and the "in range" code has a glitch somehow related to that i.e. it somehow switches too soon.

    Quote Originally Posted by ReluctantSamurai View Post
    Does the same thing happen with a faction at war with another faction, rather than rebels?
    good question - vanilla factions only start at war with rebels and this bug only seems to apply to armies given orders to attack before they've moved and so by the time the factions get into wars with each other most of the starting armies have moved (apart from the ones that are already stuck). However it might happen in mods that start factions at war with each other?

    will have to try and test for this

    (though now i think of it scipii have no available rebel targets and begin a war in sicily soon after the start - will have to check to see what happens there)

    the only other way i could imagine this happening is if a newly spawned general was given a target (rebel or faction) before they moved out of a city.

    Quote Originally Posted by ReluctantSamurai View Post
    Seen that scenario played out repeatedly
    yes - a faction at the start may only have one or twp targets so if one is bugged their expansion is handicapped from the beginning.


    Quote Originally Posted by ReluctantSamurai View Post
    Sometimes, the solution isn't in a straight line...
    all's well that ends well

    #

    vanilla armies that start outside settlements (may have missed a few)

    julli (2)
    1) rebel target < 1 turn away
    2) watchtower

    brutii (2)
    1&2) no available land rebel target -> naval landing

    scipii (1)
    hmm?

    gauls (2)
    1) rebel target (stuck)
    2) watchtower

    britons (2)
    1) watchtower
    2) no available rebel target (moves to settlement)

    dacia (1)
    rebel target but > 2 turns away

    thrace (1)
    rebel target (stuck)

    numidia (1)
    rebel target > 2 turns away

    carthage (1)
    no land rebel target (on sicily)

    egypt (1)
    watchtower

    parthia (1)
    rebel target (stuck but only briefly as armenia takes target)

    armenia (1)
    watchtower

    pontus (1)
    rebel target > 2 turns away

    key thing is it's easy to fix - just move the army closer or farther away
    Last edited by nikolai1962; 01-30-2018 at 01:41.
    It's not a map.

  5. #5

    Default Re: Game AI stuff (1.5)

    Does the same thing happen with a faction at war with another faction, rather than rebels?
    seems so - the Scipii are given Syracuse as a target by the senate but the army outside Messana is < 1 turn away so isn't stuck and attacks on turn one but if you move him > 1 turn's move away he doesn't move.
    It's not a map.

  6. #6

    Default Re: Game AI stuff (1.5)

    this happens on MTW2 as well - most starting armies are either < 1 turn away or > 2 turns away from their rebel targets and so move to attack on turn one but a few are > 1 but < 2 turns away e.g. Vaasco for Spain and won't move. move Vaasco > 2 turns away from the adjacent rebel region settlements and he moves to attack on turn one.

    only had a quick look but at first glance both Venice and Scotland also have a general stuck at the start for the same reason.
    It's not a map.

    Member thankful for this post:



  7. #7
    Senior Member Senior Member ReluctantSamurai's Avatar
    Join Date
    Feb 2008
    Location
    USA
    Posts
    2,483

    Default Re: Game AI stuff (1.5)

    key thing is it's easy to fix - just move the army closer or farther away
    I just don't understand why such a simple fix wasn't done by the devs I can see missing problems a number of years into the game, but some of these stacks stalling within the first few moves should have been spotted if proper play-testing had been done
    High Plains Drifter

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO