Building Your Own Planetary Annihilation AI

Discussion in 'Mod Discussions' started by exodusesports, October 4, 2015.

  1. exodusesports

    exodusesports Well-Known Member

    Messages:
    191
    Likes Received:
    673
    ai_build_guide.png

    So before we begin this guide to building your own Planetary Annihilation AI, let me give you my credentials. My name is Quitch and I used to run AI Central for Total Annihilation and Total Annihilation Kingdoms, as well as creating my own Queller AI for these games. I never really became a fan of Supreme Commander, but thankfully Sorian picked up the reigns with his now famous Sorian AI.

    Now here we are now with Planetary Annihilation. Sorian is making the official AI and I’m modding it.

    I’m going to lay out what I’ve learned, in brief, to give you a headstart on creating your own AI. This guide doesn’t cover everything, that would be a guide vastly more complex than this, but it will provide you with enough to set you well on your way.

    Some elements of the AI are moddable while others are not. You can setup build lists for structures, units and platoons. You will provide prioritisations and the criteria which must be met for the build to occur. You can also choose the composition of the AI’s platoons and which micro behaviour is assigned to which squad.

    There are two key elements of the AI: the personality and the brain.

    Read more here
    maxcomander, huangth, Nicb1 and 5 others like this.
  2. devoh

    devoh Well-Known Member

    Messages:
    445
    Likes Received:
    404
    I've read through it once and really like it. Though it created so many new questions my head exploded, thanks @Quitch, now I have a mess to clean up. :)

    Should we start an "AI for noobs" thread? to keep people like myself from spamming your AI threads?
  3. devoh

    devoh Well-Known Member

    Messages:
    445
    Likes Received:
    404
    Do you AI'ers use git or some kind of RCS?
  4. Quitch

    Quitch Post Master General

    Messages:
    5,856
    Likes Received:
    6,045
    I'd use the Sorian PA Titans AI thread or this thread, which is all about getting started on AI after all.

    My workflow is at the bottom of the guide. I use Git for Queller, more specifically I use GitHub Desktop and GitHub.
    Last edited: October 7, 2015
    devoh likes this.
  5. maxcomander

    maxcomander Active Member

    Messages:
    328
    Likes Received:
    129
    hi quitch, thankyou for the awesome guide.

    I've decided to build a survival game mod and am working through your guide but got a bit stuck on personality's, does the ai.js file go in the root client mods folder? (sorry for the noob qestion)
    Quitch likes this.
  6. Quitch

    Quitch Post Master General

    Messages:
    5,856
    Likes Received:
    6,045
    It should go in \client_mods\yourmod\ui\mods\modname\

    I don't think the guide says this, quite the oversight on my part, I'll get that fixed.
    maxcomander likes this.
  7. maxcomander

    maxcomander Active Member

    Messages:
    328
    Likes Received:
    129
    Thanks for the info, sadly I'm unable to get it working my ai shows up in pamm fine but not in the ai personality drop down menu.

    I'm in a bit over my head here lol, Is there any chance I could get some help? (I hope it's ok to ask you).

    I've included a zip of what I've done so far just in case.

    For the server I just copied over ubers settings from pa_ex1/ai

    Attached Files:

    Last edited: October 27, 2015
    Quitch likes this.
  8. Quitch

    Quitch Post Master General

    Messages:
    5,856
    Likes Received:
    6,045
    I'm afraid that, again, this is my fault. It seems I missed something from the example personality modinfo.json. The example ended on priority, but in fact the end should be

    Code:
      "priority": 100,
      "scenes": {
        "new_game": [
          "coui://ui/mods/Queller-AI-Personalities/Queller-AI-Personalities.js"
        ]
      }
    I've updated the guide. Sorry about that.

    To get a proper copy of Uber's AI for a mod you'd need to copy over pa/ai and then overwrite it with pa_ex1/ai. However, if you only want to adjust the personality there's no need to include a server mod at all, your personality mod will be used by the vanilla AI.
    stuart98 and maxcomander like this.
  9. maxcomander

    maxcomander Active Member

    Messages:
    328
    Likes Received:
    129
    Ive not ruled out server mods I just thought I'd try to keep things simple as possible and get the ai up and running with basic tweaks and then adjust/playtest/repeat until I get the desired result. (I have zero modding experience beyond map making in sup com)
    To this end I've gone with loosing the server mod completely for now but I still cannot see my ai in the ai personality drop down in game. Shows up fine in pamm and no longer needs the server dependency.

    Here is my modinfo.json
    Code:
    {
      "context": "client",
      "identifier": "com.pa.megalomas.SurvivalAi",
      "display_name": "Survival Ai v1.0",
      "description": "for use with survival maps",
      "author": "megalomas",
      "version": "1.0",
      "build": "89755",
      "date": "2015/10/26",
      "signature": "not yet implemented",
      "forum": "forum thread URL",
      "category": [
        "ai",
        "titans"
      ],
      "product": ["Titans"],
      "id": "SurvivalAi",
      "icon": "http://i.imgur.com/HjPqMBL.jpg",
      "priority": 100,
      "scenes": {
        "new_game": [
          "coui://ui/mods/Survival Ai v1.0/Survival Ai v1.0.js"
        ]
      }
    }
    And this is my ai.js
    Code:
    (function() {
      var extensions = {
        'Survival mode land': {
          percent_vehicle: 0.60,
          percent_bot: 0.40,
          percent_air: 0.00,
          percent_naval: 0.00,
          percent_orbital: 0.00,
        },
        'Survival mode water': {
          percent_vehicle: 0.00,
          percent_bot: 0.00,
          percent_air: 0.00,
          percent_naval: 1.00,
          percent_orbital: 0.00,
        },
      }
      var baseline = model.aiPersonalities.Absurd || {
        percent_vehicle: 0.45,
        percent_bot: 0.25,
        percent_air: 0.2,
        percent_naval: 0.05,
        percent_orbital: 0.05,
        metal_drain_check: 0.54,
        energy_drain_check: 0.65,
        metal_demand_check: 0.71,
        energy_demand_check: 0.8,
        micro_type: 2,
        go_for_the_kill: true,
        priority_scout_metal_spots: true,
        enable_commander_danger_responses: true,
        neural_data_mod: 1.0,
        adv_eco_mod: 1.3,
        adv_eco_mod_alone: 0.85,
        fabber_to_factory_ratio_basic: 1.0,
        fabber_to_factory_ratio_advanced: 1.0,
        fabber_alone_on_planet_mod: 2.0,
        basic_to_advanced_factory_ratio: 0,
        factory_alone_on_planet_mod: 0.5,
        min_basic_fabbers: 2,
        max_basic_fabbers: 6,
        min_advanced_fabbers: 3,
        max_advanced_fabbers: 20
      }
      Object.keys(extensions).forEach(function(name) {
        extensions[name] = _.extend(JSON.parse(JSON.stringify(baseline)), extensions[name])
        extensions[name].name = name
        extensions[name].display_name = name
      })
    
      _.extend(model.aiPersonalities, extensions)
    
      model.aiPersonalityNames(_.keys(model.aiPersonalities));
    })()
    Last edited: October 28, 2015
  10. Quitch

    Quitch Post Master General

    Messages:
    5,856
    Likes Received:
    6,045
    The issue is you calling the file ai.js, but referencing "Survival Ai v1.0.js" in your modinfo.json file.
  11. maxcomander

    maxcomander Active Member

    Messages:
    328
    Likes Received:
    129
    I thought that, I tried renaming it last night but I could have made a mistake in the spelling. Will try again tonight, thankyou for all your help and patience btw it is much appreciated: )

    Update tried renaming it, tried running the uber launcher instead of steam nothing I seem to do seems to makes any difference. I bet I will kick myself when I eventually crack it lol.
    Last edited: October 30, 2015

Share This Page