The sorian PA AI thread

Discussion in 'Planetary Annihilation General Discussion' started by Quitch, December 23, 2014.

  1. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    How does EnemyPresenceOnPlanet differ from AloneOnPlanet? My guess is that AloneOnPlanet is false until proven otherwise, while EnemyPresenceOnPlanet is false until proven otherwise.

    Does this PTE have the AI placement check optimisations in it?

    Lots of cool sounding changes :)
    Last edited: July 16, 2015
  2. theseeker2

    theseeker2 Well-Known Member

    Messages:
    1,613
    Likes Received:
    469
    I have no idea how the AI works, but AloneOnPlanet sounds like it also checks for allies, determining how the AI should behave if there is an ally on the planet or not.
    websterx01 likes this.
  3. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    Sorian, what's the difference between fast, artillery and general in terms of squad behaviour? Also, will the AI benefit from having different unit types with the same behaviour split into different squads?
  4. Sorian

    Sorian Official PA

    Messages:
    998
    Likes Received:
    3,844
    Yes and yes.

    EnemyPresenceOnPlanet checks to see if AI knows about actual enemy units on the planet.

    AloneOnPlanet checks to see if it knows or assumes there is an enemy on the planet or that there is an enemy on the way to the planet via transport. It will assume an army is on a planet if it was marked as a starting planet and the AI has not yet scouted the planet, or if it saw an enemy send a unit to that planet and has not scouted the planet since that transport.

    Yes, it should.

    Fast: Used for microing when the neural net determines that is the best course of attack.
    Artillery: Assumes these are longer range than average units and uses them as such.
    General: General rank and file units.

    So, specifics.:

    When microing:
    The Fast squad will break off and micro back and forth near their max range,
    The Artillery squad will break off and attack from near their max range.
    The General squad will attack from near their max range
    The Close squad will issue an attack order.
    The Defense squad will tag along with whoever is going to be furthest away.

    When attacking from range:
    The Artillery squad will break off and attack from their max range.
    Everyone else will tag along with the Artillery squad.

    When issuing an attack:
    All attack squads issue an attack.
    The defense squad tags along with whoever has the longest range.
    stuart98, cdrkf and Quitch like this.
  5. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    I'm considering whether it's worth combing some of my blocks across personalities, do 200 fabbers hitting a bunch of blocks and failing on the first boolean contribute a meaningful hit to the AI sim?

    Queller can build a lot of fabbers, so anything I can do to optimise its performance :)

    Where a squad has multiple units with different ranges will it use one range, or move each unit to its own max range?
    Last edited: July 19, 2015
    stuart98 likes this.
  6. Engineer1234

    Engineer1234 Well-Known Member

    Messages:
    325
    Likes Received:
    291
    Could one of you explain how I should interpret AI build tests ?
    I would like to make the AI build way more defences, and I'm trying to figure out how.
    I think I need to edit the file \pa\ai\fabber_builds\fabber_defense_builds.json

    These tests, does the result need to be true or false for the AI to build the basic air defense ?
    If so, having "less than 1" I understand would make the AI build one, but how does "equal to or more than 2" make sense ?

    "test_type": "UnitCountInBase",
    "unit_type_string0": "Structure & Basic & AirDefense",
    "compare0": "<",
    "value0": 1

    "test_type": "UnitCountInBase",
    "unit_type_string0": "Structure & MetalProduction",
    "compare0": ">=",
    "value0": 2

    And then this bit, does this mean "build 1 AA turret near every mex" ?

    "placement_rules": {
    "buffer": 2,
    "placement_type": "FromMainBasePerimeter",
    "unit_count_rules": [{
    "unit_type_string": "Structure & MetalProduction",
    "alliance": "Ally",
    "compare_type": ">=",
    "range": 50,
    "count": 1

    Basically I would like to be able to have the AI build x number of turrets near every factory and mex, and be able to also make the AI build my new engineering station structure near turrets for automatic maintenance :)
  7. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    "test_type": "UnitCountInBase",
    "unit_type_string0": "Structure & Basic & AirDefense",
    "compare0": "<",
    "value0": 1

    This test is saying: If there are < 1 units in the base of type STRUCTURE and BASIC and AIRDEFENSE (this is the Galata) then test passed, continue to the next test, or if this is the last test then build the thing.

    "test_type": "UnitCountInBase",
    "unit_type_string0": "Structure & MetalProduction",
    "compare0": ">=",
    "value0": 2

    Are there two or more units of type STRUCTURE and METALPRODUCTION (basic and advanced MEX) in the base, if so then test passed.

    "placement_rules": {
    "buffer": 2,
    "placement_type": "FromMainBasePerimeter",
    "unit_count_rules": [{
    "unit_type_string": "Structure & MetalProduction",
    "alliance": "Ally",
    "compare_type": ">=",
    "range": 50,
    "count": 1

    When placing the thing I want to build place it within 50 units (of measurement) of a unit of type STRUCTURE and METALPRODUCTION and leave a gap of two units between it and anything else. I couldn't tell you the difference between the various placement_types though.
  8. Engineer1234

    Engineer1234 Well-Known Member

    Messages:
    325
    Likes Received:
    291
    Are these the things that also make the AI decide to try and build the thing ? or does that happen based on the priority.
  9. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    Yes, it will go through its blocks in order of priority and carry out the first task for a unit where the instance count hasn't been hit yet and all the tests are passed.
  10. Engineer1234

    Engineer1234 Well-Known Member

    Messages:
    325
    Likes Received:
    291
    Is that the whole thought proces of the AI ? check to see what makes the most sense to do next by priority and tests ?
    Maybe I'm a bit naïve but I thought there would be some kind of plans structured more like a list of desires first.
    This makes it kinda hard to modify the way it plays.

    So if I understand it correctly, the AI goes through the list of possible build items from high priority number to low priority number and builds the thing if it passes all the tests like "desire metal".

    This seems backwards to me, "desire metal" should trigger a task to build mexes, or am I thinking too much like a fleshy person and not enough as a machine :p
    This is my first time modifying AI behavior in any game so please excuse me if my assumptions are really silly.
  11. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    Correct. If it matches the builder, is below the instance count and passes the tests then the AI does it.

    I've setup a (very) limited wiki on the subject.
  12. andrehsu

    andrehsu Active Member

    Messages:
    366
    Likes Received:
    120
    From the way I see it, it doesn't really matter, since they can probably do multiple checks in a second, and isn't it better to be always building?
  13. Sorian

    Sorian Official PA

    Messages:
    998
    Likes Received:
    3,844
    For simple boolean checks the perf cost will be minimal. Also, the AI is throttled in how many fabbers can update at one time.

    Depends on the behavior. For a straight attack the attack order handles range, so it would be per unit. For Keep at Range it will be the longest range of the platoon. For Micro, it will be the longest range per squad.
    Quitch likes this.
  14. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    Do factories get put in this pool too? I saw another example of an anti-nuke launcher not building for a while and the AI wasn't close to the unit limit yet and the factory logic is literally JUST DO IT without cost checks. Damn, I need to get some video of when this happens.
  15. Sorian

    Sorian Official PA

    Messages:
    998
    Likes Received:
    3,844
    Nope. Factory build checks are usually a lot cheaper (no build placement checks), so the AI is not restricted on the number of factories that can attempt to build. The only restriction is the server AI unit cap. I will make a change to not do unit cap checks for factories that do not produce mobile units. That may help.
    crizmess and Quitch like this.
  16. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    If I might suggest one change, and that's to reduce the range they engage at. I see micro'd Dox losing battles they should win because it appears the AI measures range by the front rank of the squad. This means its micro is actually keeping large numbers of Dox out of the battle. It also means that when they face tanks the tanks retreat and so the Dox keep darting in and out of range, making the situation even worse as they don't maximise their fire time while the tanks don't care because they only fire every two seconds.
    Last edited: July 22, 2015
    stuart98 likes this.
  17. Sorian

    Sorian Official PA

    Messages:
    998
    Likes Received:
    3,844
    Yeah, I already did some work on that. Not sure when that will go out live.
    stuart98, cdrkf and Quitch like this.
  18. Engineer1234

    Engineer1234 Well-Known Member

    Messages:
    325
    Likes Received:
    291
    I'd like to jump in on that, I doubled the range of laser turrets, and I noticed AI armies with lots of advanced units including shellers hovering at artillery range from the turret.
    The shellers were firing but all other units have a range that does not reach the turret, and were getting shot up for no good reason.
    In these situations the shellers should really split from the group and stay at range, and all other units should rush the turrets, they could have easily won, at least that's how I order my armies around...

    An artillery unit is a support unit and should split from the main battle tanks once the shooting starts.
  19. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    Also, can the AI handle multiple squads of one type? If it has two artillery squads for example, what happens?
    Last edited: July 22, 2015
  20. Sorian

    Sorian Official PA

    Messages:
    998
    Likes Received:
    3,844
    Nope, one squad per type. If you list multiple squads of the same type in the json, they all get dumped into one squad together,
    stuart98 and Quitch like this.

Share This Page