Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

AI question: weapons or targets first?

Discussion in 'General Discussion' started by lord_goldemort, Sep 27, 2020.

  1. lord_goldemort

    lord_goldemort

    Joined:
    Oct 5, 2017
    Posts:
    11
    Working on game AI at the moment, and I'm deliberating the following question.

    My actor has a bunch of weapons. There are a number of possible targets. Do I pick a target first, then select the best weapon for that target? Or do I select a weapon and then find the target that it works best on?

    Thoughts?
     
  2. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    You need more factors and weight their importance. Which enemy is closest, which enemy is most dangerous, your current weapon works best against which enemy etc, etc. You also need alot of fuzzy utility ai logic so it feels natural :)
     
  3. lord_goldemort

    lord_goldemort

    Joined:
    Oct 5, 2017
    Posts:
    11
    Cheers. I don't have the concept of a "current weapon". All are potentially selectable with no time penalty. Each weapon has a potency measure based on its level, but that doesn't mean too much if a target has some counter-measure to that weapon. So is your position: evaluate all weapons against all targets and pick the best?

    Distances don't figure too much at the moment, though they may at some point (it's a turn-based thing). So the "closest" enemy is irrelevant.

    As a bit of a complicating factor. Weapons are dynamically configurable. Lasers can have frequencies shifted, for example .This makes the search space for "all possible options" highly dimensional enough to start being quite expensive. So instead I'm thinking that picking a target first makes sense. My criterion is based on a "ruthlessness" value - the more ruthless actors tend to take out the weaker targets first, the less ruthless ones the stronger.
     
  4. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,984
    My suggestion is to stop thinking of AI decisions as being right or wrong, but instead think of it as crafting a player experience. You could create a very tactical and stealthy AI, a dumb brute AI, etc. Each one will give players a different kind of satisfaction when playing against them.
     
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,514
    AIs which always pick the optimial choice are boring anyway. Presumably you're not making a chess game aimed at chess enthusiasts, so "optimal decision making" probably isn't a selling point.

    Imagine how boring Metal Gear Solid would be if the guards actually did a good job of guarding important locations. The fact that their patrols are flawed is what makes the game interesting.

    From what you've written we know nothing about the rest of your game, so we can't make suggestions about what might be interesting in your context.
     
  6. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,324
    Whichever you prefer.

    I'd expect AI to have a preferred mode type, and only switch weapons when forced to. For example, you could have a melee charger character with a sword who would only pick up a sidearm when other options are exhausted.

    And you could have a sniper with a knife. This one would only switch to knives when the rifle is no longer usable.

    Then there's forced weapon switch when ammo runs out.

    Also, I think that Ai will not pick the "next best target", but "next suitable target" instead. For example, it could be any target currently visible, a guy the AI agent hates in particular and so on. Unless they're a squad, NPCs shouldn't be really pickinng the enemy they'd dispatch most efficiently. If they are a squad, they could do that and cover each other, as long as squad commander is alive, that is.