Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

AI - Decisions Model

Discussion in 'Triggers & Scripts' started by JoHnyW, Dec 4, 2013.

  1. JoHnyW

    JoHnyW

    Joined:
    Oct 8, 2007
    Messages:
    154
    Resources:
    0
    Resources:
    0
    Hi !
    I wonder if it is possible to make a decissions model for AI controlled player. I mean for example to make AI know what kind of item for hero shall it buy or what research to do at certain situation. Do you posses any ideas/examples of such models in W3 modding?

    http://en.wikipedia.org/wiki/Decision_model

    is it maybe possible to make a Perceptron which would help AI in for example choosing what development to do ?

    http://en.wikipedia.org/wiki/Perceptron

    My certain usage is footy frenzy so I want to make a kind of model which would make AI decide if it shall upgrade tier, buy items for hero or upgrade units. When you write AI how do you deal with such problems ?
     
  2. Grey Nightmare

    Grey Nightmare

    Joined:
    Feb 24, 2009
    Messages:
    2,852
    Resources:
    0
    Resources:
    0
    There's a GUI AI Editor built into the World Editor, though if I recall correctly it only works for melee-style games.

    You'll have to custom trigger/code any AI behaviour for abstract maps.
     
  3. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    It's possible, but the work needed for it depends on how "smart" the AI would be
     
  4. Cokemonkey11

    Cokemonkey11

    Wurst Reviewer

    Joined:
    May 9, 2006
    Messages:
    3,271
    Resources:
    18
    Tools:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    2
    JASS:
    7
    Resources:
    18
  5. DysfunctionaI

    DysfunctionaI

    Joined:
    Mar 6, 2006
    Messages:
    281
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Edit: You would absolutely need JASS, in case you were planning on doing it in GUI.

    You could probably script that exactly how YOU would play the game.

    When footies starts, how do you select your hero?

    - Base it off what your teammates picked
    - Lean more towards the OP heroes

    So then script that.

    - Get your teammates heroes, and do a comparison. This means you'd need pre-defined variables for every hero, and judge for yourself what hero is compatible with what, and add them to a group.

    - Once you have a pool of heroes that are compatible with your teammates, let random pick a hero, but give the OP heroes (pre-defined) a higher chance at being randomed, based on how OP you judge they are.

    ===============================
    That would be how I would write hero selection; exactly how you would play the game, just take it step by step.

    Picking items would almost be the same pattern of decision making. You'll need lists of every item in the game and how relevant they are with each hero. Then, leave it up to random to decide what item to buy, granting better items with a higher chance to be randomed.

    Periodicly change the relevancy of items based on a formula that has the following variables:

    Current Gold, Game Time, Hero Level, and Gold Per Minute (make a simple timer to get ur gold per minute)

    So let's see what would happen. A periodic timer fires that asks the AI if it should buy an item. It runs through your list, recently updated by ur gold, level, time, and gold per minute.

    You have 500 gold, but its 10 minutes into the game, and you're getting gold rather slowly. The item relevancy changes to drastically prefer an item to help you get gold quickly, like a Scroll of the Beast.


    ========

    Is this the proper way to do this? No clue, but it's logical and seems like it would work. There really is no "one answer" on how to make AI, that's what separates good and bad AI, based on how clever they are. You could make your AI WAY less complicated, but it just wouldn't perform as well, it's up to you on how much effort you wanna put into it.
     
  6. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    He can do it in GUI, seriously... it will just be plain hard and time consuming to do advanced AI on that
     
  7. NightSkyAurora

    NightSkyAurora

    Joined:
    Mar 1, 2013
    Messages:
    528
    Resources:
    8
    Models:
    4
    Spells:
    4
    Resources:
    8
    Safe the hero's role statics in a hashtable with a integer that rates it's nuke, tank, stickyness (hard to escape) assult, evading, atk speed advantages, ect and then makes it buy items that improves that. So if it is tank, it will buy items that gives HP, HP regen, amor and some attack damage. If it's attacks stuns, cleave, steals HP and stuff then you make it buy items that gives it attack speed and movement speed. However you can't trigger the AI to reason wich item is better. You need to put items in groups based on their role and make the AI decide by using it's raitings. I'm also making AI in GUI and it is easy if you write the ITE down on paper and starting at the basics. Then you improve that step by step :)
     
  8. DysfunctionaI

    DysfunctionaI

    Joined:
    Mar 6, 2006
    Messages:
    281
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    I used to write a lot of AI in GUI too, but I would always hit snags. Now that I'm learning JASS, I realized how those snags would never have occurred and I'd like to try it again, so I just said that 'JASS is required' based on my experience.

    Sure, you can do it in GUI, but it's like making a mountain out of a molehill (again, totally based on how smart the AI is).
     
  9. JoHnyW

    JoHnyW

    Joined:
    Oct 8, 2007
    Messages:
    154
    Resources:
    0
    Resources:
    0

    I think this idea is easy and might work cool.

    But I guess I have idea how to improve it.

    Lets group heroes by thieir main attribue (strengh, intelligence, agility) and put types of items into 3 different arrays, some items may be contained in both. And than make an algorithm which will be like

    Code (Text):

    PSEUDOCODE:

    if (hero_main_attribute==strengh)
    then
    {
    call function BuyingItemDecissionModel
    }

    //===================================

    BuyingItemDecissionModel takes 3 arguments (Current_Amount_of_Gold , PlayerNumber, ArrayOfItems)
    returns ThingToBuy
    {
    if (Gold==100)
        {
         Buy Item=Potion of Healing
        }
    if (Gold>=100,Gold<=300)
       {
        Improve Units damage
       }
    if (Gold>=1000,Gold<=2000)
        {
        Improove Tier
        }
    if (Gold>3000)
        {
         Buy Item "Epic Sword of Ethernal Destruction"
        }
    // and so on...
    }

     
    The argument "Items array" of decisions model function will be different for every attribute so it might be StrenghtItemArray, IntelligenceItemArray, AgilityItemArray

    What do you think will it work ?

    Another problem is that I dont have much experience in making triggers or jass programming would you help me a little how to make those arrays with both "Hero's main attribute" and "Types of items" and make it work together on an example?
     
  10. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    I highly doubt that machine learning techniques can successfully used for wc3 AI, for different reasons. But if you have more concrete ideas id like to hear them.
     
  11. JoHnyW

    JoHnyW

    Joined:
    Oct 8, 2007
    Messages:
    154
    Resources:
    0
    Resources:
    0
    So my idea is shown in previous post but I dunno how to make trigger or what I would maybe prefer JASS Code doing it


     
  12. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Realistic AI can be made using a Bayesian decision tree. The idea is that each action is given a value from a Bayesian decision tree and the one with highest figure of merit is executed.

    The figure of merit is generally referred to as probability although it is completely logical and has nothing to do with chance although one could add chance to a figure of merit but this generally can result in sub-optimal decisions.

    These trees are often slow to evaluate or have nodes that are hard to define. As such it is often a better solution to simplify into simple conditional statements. This however gives only very basic decision capabilities that will often not factor in enough sensor input to make a good decision and is the main reason why AI suffer compared to real human intelligence.

    For item purchase it seems that such a tree would be the perfect solution. You could factor in measurements like current stats, gold and current opponents to make a much more accurate item decision choice than just buying random items or items you can afford. The slow evaluation of such decision trees is meaningless since it only runs once every few minutes.

    To actually get to the shop to buy items needs to be made as part of the tactical AI component. As such you will probably be better using a simple state machine to make this decision as tactical AI can evaluate multiple times a second and state machines are fast.
     
  13. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    your code is not machine learning based
     
  14. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    It is not feasible to use perceptron based AI for games like WC3. The AI is too complex (needs large perceptron network) and perceptrons are too slow (especially in JASS) for it to work well in real time. Some specialist hardware, such as from intel, does allow real time perceptron use but this is not widely available enough and certainly not supported by WC3.

    Some games claim to use such learning techniques for their AI but I believe that is all marketing hype. Mostly they use Bayesian networks which can also be trained by adjusting threshold values. Unlike perceptrons, it is much easier to train a Bayesian network and they are much simpler to evaluate so can be used in real time.

    Bayesian networks are not an easy thing to make. They work wonders but need a lot of development behind them.
     
  15. looking_for_help

    looking_for_help

    Joined:
    Dec 12, 2012
    Messages:
    974
    Resources:
    5
    Spells:
    2
    JASS:
    3
    Resources:
    5
    That has nothing to do with Machine Learning, what you posted are just if statements. You should read the links I sent you.


    It is possible to apply Neural Networks to take over specific decisions a typical AI has to perform. Here is a link which evaluates this even for Warcraft 3 (you need an IEEE Acount):

    IEEE: Evolving Neural Controllers Using GA for Warcraft 3-Real Time Strategy Game

    If its possible to do so in Jass is of course another question. But NNs have already been applied in several games... Backgammon's worlds best AI is a MLP which even "invented" new moves which are today used by professional backgammon players (free publication):

    TD-Gammon, a Self-Teaching Backgammon Program, Achieves Master-Level Play
     
  16. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    There are other machine learning techniques than perceptrons, for example Bayesclassifier, gaus mixture models, support vector machines, linear discriminant analysis etc.
    Im not saying that i think these models are suitable for wc3 ai, i just said im interested in the idea (well knowing that this will never be used in a wc3 map).

    Also perceptrons arent thaat slot, what is really costly is the training with backpropagation (also there are newer techniques for training deep networks). But once they are trained the value retrieval is quite fast (some evaluations of sigmoidal or gaussian functions).

    €: nice paper, looking_for_help :D
     
  17. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Yes but these are usually have a very limited percept pool and frequency. Generally other approaches could be used to get the same results with drastically improved performance.

    At what game? The paper is unclear but makes references to "board state" so I am guessing chess? If so, chess is hardly an AI challenge since the number of states and rules involved are small compared to most modern PC games. You also do not have the time constraints that RTS games have.

    Chess -> 60 decisions total (about) Time limit is in the minutes.
    SC2/WC3 -> >100 decisions a minute, more = better. AI with >1000 would be immune to many common strategies. Baneling bust? Split marines and micro one at a time. Enemy army attacking base? Surround individual units with your units so they cannot run.

    Except how often do you do that? How many inputs? How large is its internal state? How do you train the thing to start with?
     
  18. looking_for_help

    looking_for_help

    Joined:
    Dec 12, 2012
    Messages:
    974
    Resources:
    5
    Spells:
    2
    JASS:
    3
    Resources:
    5
    That certainly is true. I also think the the thread opener should start with something more simple as those techniques are quite difficult and he seems to be new to AI programming.

    For example Warcraft 3, see the first paper. There are other ones like for SC1 or some old first-person shooter I can't remember now.

    It is not meant that the net performs the whole AI of the game but only one very specific task, like choosing the right army mix or the right items (like described in the paper). You then could build up the AI with several modules of (different) nets, where everyone has a different task to solve.
     
  19. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    this
     
  20. DysfunctionaI

    DysfunctionaI

    Joined:
    Mar 6, 2006
    Messages:
    281
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Says you gotta purchase it?! Fck, I wanna see it lol. And for SC1, you're talking about BWAPI ? That stuff is sooo cool.. there's a bunch of vids on youtube of AI tournaments.