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

What are some componenet I need to add to my A.I?

Discussion in 'General Discussion' started by GTHell, Oct 15, 2016.

  1. GTHell

    GTHell

    Joined:
    Jan 5, 2016
    Posts:
    256
    Here, I have an A.I that raycast 360 degree per frame and try to avoid obstacle and always choose a new corridor like a self driving car but it get slower overtime due to tiredness > 10; Stop = true. Well, It's bored as hell. This is enough for a labyrinth kind of game but take a look back at Pac man, all enemy has personality!

    I'm thinking of giving it emotion and personality base on other factor and situation that can affect it, but I don't understand what emotion is!!!

    Sorry, English is not my first language.
     
  2. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,981
    If you don't know what emotion is, nobody can tell you ;)
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    Emotion is a state of a brain that changes likelyhood of taking specific actions.

    Anger - offensive and aggressive actions more likely.
    Fear - defensive actions and fleeing more likely.
    Disgust - avoidance of contact.

    Arguably those evolved from evolutionary defensive mechanisms.

    To give your AI a personality you'll need to have parameters that affect ai behavior and have differnt AI use different set of parameters, then periodically make ai select a choice which would be based on ai parameters. The selection of choice can be handled by weighted random selection from a list or something along the lines.
     
  4. GTHell

    GTHell

    Joined:
    Jan 5, 2016
    Posts:
    256
    That what I was thinking before but to go beyond that I need to define what those parameters is then doing a harsh and then the personality and emotion will be base on that!
     
  5. GTHell

    GTHell

    Joined:
    Jan 5, 2016
    Posts:
    256
    Actually I know what it is but I don't know what it made of! Wikipedia seem not to help me out. So, someone who used to experienced a higher consciousness might be helpful (Not Buddha).
     
  6. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    Umm (-_-). To be honest, I'm not sure why you'd have any difficulty with this. Have you played Sims? It had a simple example needs/mood based behaviors, might or might not apply to your game.

    Put yourself into AI's shoes. Think about what you're trying to do and why, and what your options are.
    For a start, what is your game about? Think about it. What does AI want? Why is it in labyrinth? Those kind of things.

    Then generalize the problem and reduce it to a set of behaviors and controlling parameters.
     
    angrypenguin and Kiwasi like this.
  7. GTHell

    GTHell

    Joined:
    Jan 5, 2016
    Posts:
    256
    Yeah, Maybe I'm too stupid!

    Maybe I should use MBTI in this one. I'm just recreate PacMan in 3D with smart A.I. But the ideas is build the great A.I because I got help from someone who specialize in A.I and I'm trying to learn to make a good A.I before I learn the neural network and other fancy stuff about A.I.
     
  8. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,981
    When you want to make something more 'lively' there's no substitute for iteration. Just start somewhere and try out things until you get what you want.

    I dunno, animate your AI to punch the wall if it gets angry, dance if it's happy, that sort of thing. Most of the useful effects will be animation or sound effects.

    If you don't know when to make it happy or angry, well, what's your game all about? Is there any reason for it to be angry or happy? If not, it is probably as bored with the game as your players are going to be, so create more of a dramatic structure, a story etc.

    If you let us know what the game is about, and what you've tried out so far, it might be possible to give some useful answers.
     
  9. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    There's "AI" and then there's "Artificial Life".
    The purpose of AI is to solve problem. The purpose of Aritificial Life is to be entertaining.

    "Smart PacMan ai" would be along the lines of "explore entire dungeon". There's not much to work with. You need more behaviors and options for the AI to show a character.

    In case of pacman enemy ai, your configurable parameters could define how likely the enemy is to :
    1. Chase the player.
    2. Flee the player.
    3. Do nothing.
    4. Switch directions.

    You could also add different movement speeds to it. Make one enemy stand on the spot for a long time, occasionally taking few steps, another one would be pursuing the player reletnelessly, and some other will wander around dungeon at random.
     
    RavenOfCode likes this.
  10. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    The thing about A.I. is, people try to be very specific and try to get all scientific with it, well to be honest it doesn't need to be so complicated... Give it some enums, happy, mad, sad, depressed, etc or whatever. Then have some states that change the emotion enum.... Such as if the A.I. is idling, and you the player sneaks into a room and shoots 2 other idling A.I's, to then make the 3rd AI, change it's enum state to Scared/Hide or something, then make that method of code find the nearest thing to hide behind.

    Long Story Short:

    Have A.I. scanning the area..
    Have A.I. detect things that happen in that area..
    Have A.I. react to an Action that results from an action that happens in the area it cares about..

    It might sound complicated, but if you want decent A.I. that has pseudo emotions, then just start thinking
    about things that might trigger it, not what happens in your brain chemically, but just think of it
    in simplistic terms, no need to overly-complicate it unless your creating an A.I. that has some real
    practical value in the world outside of games, which in that case I wouldn't use Unity any ways for that.
     
    Kiwasi likes this.
  11. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,980
    A neural network can be an excellent AI tool in some cases, but neural networks generally are not very useful in games. Generally speaking, neural networks take a lot of CPU time to train. There may be some complex AI events that you want to train based on many variables, and neural networks can be useful for those as long as you can run all of the neural network training during game development instead of at runtime.

    For actually useful game AI, read about these topics:
    finite state machines
    behavior trees
    utility AI
    possibility maps
    probability maps
    kungfu circules
    route planning AI (specifically read about A*)
    blackboards

    Those are some AI topics that can be useful when designing games. Neural networks are usually more useful for academic and scientific situations than for games.

    As for adding personality, you can use a FSM to hold the NPC's current emotional state, and then have utility AI influence the state changes based on multiple variables. You could have an NPC's tenacity state change based on multiple values, such as health, ammo and more.

    Once you have an FSM managing the emotional state, you can expand that by having the NPC decide whether to attack or hide based on the emotional state. Then you could also tie different animations in based on the emotional state. If the NPC is feel very confident, it could twirl it's weapon around to taunt the player. If it was feeling less confident, the NPC could turn slightly sideways during attacks to make it easier for the NPC to flee.
     
  12. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,980
    A really good AI system extends beyond that. For example, a good AI system will intentionally add a delay between the detection and reaction, because real humans have a faction of a second delay. The delay varies depending on if it was a stimulus that the NPC would have been expecting or not, how close the stimulus is, etc.

    And really good AI systems often need detection systems that vary the detection abilities of the NPC depending on multiple factors, such as player movement, distance to player, FOV, etc.

    Good AI systems will implement different FOV for visual detection than for audible detection. For example, an NPC should detect a player from any direction if the distance is really short, because that is what a real person would do if they heard something. For large distances, the NPC should rely on a narrow FOV to simulate detection based on vision.
     
  13. GTHell

    GTHell

    Joined:
    Jan 5, 2016
    Posts:
    256
    Good list! But I never heard of Kungfu Panda before, haha!

    However, I'm going to use the route planning because my current script using 90% of CPU. I think advance A.I might not be an option for a casual project like this. Hmm, I should stick with A.D.I (Artificial Dumb Intelligence :D)
     
  14. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,980
    Glad you like the list. Remember that is merely an intro list to game AI topics. There are lots more AI topics to explore.