The AI of Half-Life: Finite State Machines | AI 101

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 109

  • @AIandGames
    @AIandGames  5 років тому +71

    In this AI 101 we wind the clock back to Half-Life and the heyday of the Finite State Machine. In the late 90's and early 2000's FSMs were the standard for AI behaviour in games until Halo 2 and F.E.A.R. changed everything. Plus it's crazy that it's taken me 5 years to get around to having Half-Life on the show, but here it is with all the juicy AI details explained!

    • @deadengineer6951
      @deadengineer6951 Рік тому

      i remember playing phasmophobia and hunting a ghost called thomas thompson :3

  • @DaichiKan
    @DaichiKan 5 років тому +139

    It's a tiny thing, but I loved how you pronounced Wolfenstein.

    • @murph3292
      @murph3292 4 роки тому +5

      I liked shooter at 1:00 better

    • @wacky.racoon
      @wacky.racoon 3 роки тому

      I see you are also a man of coulture

  • @RamblyBear
    @RamblyBear 5 років тому +53

    11:40 I've played through Half-Life 1 completely 4 times, in various parts countless times. I have never known the tops of bins were destructible. Other than that, fantastic and informative video. Thank you.

  • @Skaitania
    @Skaitania 5 років тому +14

    When I bought F.E.A.R. so many years ago, I'd never have thought that I would keep meeting it so often when people explain AI and game environments. I found it to be quite cool, but didn't realize that I had stumbled over a technical icon. Great explanation and visualization of FSMs. Thanks.

  • @vrakitine
    @vrakitine 5 місяців тому +1

    When I was earning my master's degree, I heard a lot about finite state machines (FSMs), but it was all theory - like clouds in the sky: there's a lot of water, but you can't drink it. I toiled for three months after graduating until I implemented my first FSM in code in 1981. Now, there is a programming methodology based on this concept - v-agent oriented programming (VAOP) - with many examples of its implementation. It's best to start learning about VAOP with this article on Medium: "Bagels and Muffins of Programming or How Easy It Is to Convert a Bagel into a Black Hole".
    With VAOP, you can implement FSM in any programming language.

  • @MattEland
    @MattEland 5 років тому +17

    Love it. Half Life's AI fascinated me for quite awhile after its release and that was a very interesting look into it. The use of schedules and goals in a FSM or HFSM is also interesting and I enjoyed the discussion of the systems limitations / drawbacks.

  • @LaMOi1
    @LaMOi1 3 роки тому +6

    AI in games was something that was so exciting around the late 90s early 2000s.
    And unfortunately the promise never delivered and has become a rather overlooked feature of modern games. I’m really hoping to see some evolution ...... soon.
    I was playing Hidden and Dangerous last night and I was struck by how better the AI is compared to similar current games. It seemed the enemy AI was making decisions, showed caution and had a sense of self preservation. It blew me away.
    What game can we point to today with impressive/stand out AI?
    All I can think of is the Forest. That’s the only game in the last 15yrs that I thought wow.
    There’s been a few games where I was impressed by the variation in AI behaviours such as MGSV and Sniper Elite 4 (the AI in that game is quite interesting!) - but neither of those games was the AI particularly astute, or effective in dealing with the player. But watching the varying behaviours exhibited by the AI is fun to watch nonetheless. And what I mean is it’s fun to watch how the AI work together as a group, and the different behaviours that come about when interacting with AI, and coordinating their efforts.
    It’s a sad state of affairs. Hoping for more in the future.

  • @dudugeorge653
    @dudugeorge653 4 роки тому +4

    I'm so glad to hear that what I'm currently learning at uni is actually used, thought they were so simple they would be considered useless in our days but well:D thanks for the surprise!

  • @vincentpol
    @vincentpol 5 років тому +14

    The way I always see it.
    FSM = States with manually managed transitions between them.
    HFSM = Stacking states dynamically to allow for semi-automated transitions between states.
    Behavior Tree = A HFSM with some extra building blocks to make more complex logic out of simple states.

  • @alexrapp7728
    @alexrapp7728 5 років тому +82

    "valves classic 1998 shitter, half life"

  • @JayMaverick
    @JayMaverick 5 років тому +50

    "Valve's 1998 shitter." I'm like yeah it's old but shitter is a bit harsh... oh he's a scotsman. =D

    • @neoflager1
      @neoflager1 5 років тому +2

      I thought he said shitter as well. haha

  • @InMaTeofDeath
    @InMaTeofDeath 5 років тому +84

    I'm a simple man, I see a half life video in 2019, I click.

    • @nfwrambo
      @nfwrambo 4 роки тому

      What about a half life game?

    • @publicalias8172
      @publicalias8172 4 роки тому

      @@nfwrambo sacrilege!!

    • @Nabo00o
      @Nabo00o 4 роки тому

      am I the only one who dislikes the fact that he didn't show the original Half-Life? I'm not sure which mod or sequel this is, but to me the core defining feature of HL is the shotgun :a

    • @cyberevil101
      @cyberevil101 4 роки тому

      @@Nabo00o Yeah lol. He's playing on Half-life: source. it came out a little after the original one. Its not a sequel nor a mod

    • @cyberevil101
      @cyberevil101 4 роки тому

      Sorry I think he is also using footage from half-life: blue shift. Which is an expansion

  • @Twisted_Logic
    @Twisted_Logic 5 років тому +3

    11:30 I actually used this same method in the decision making logic in my Capstone project.

  • @BenMclean007
    @BenMclean007 5 років тому +9

    Saw the notification and immediately started watching. Love your videos!

  • @ninjadodovideos
    @ninjadodovideos 5 років тому +3

    Since HL1's system has tasks, goals and schedules I'm curious how it is distinct from goal-oriented planning systems? I guess you'll cover this in subsequent videos about planning AI?

    • @AIandGames
      @AIandGames  5 років тому +6

      What's interesting about Half Life is that it already exposes a lot of the limitations on the FSM approach that the schedules and goals are designed to resolve. I'll definitely get into it when I cover GOAP (though I already have an episode on the AI of F.E.A.R.).

  • @3334momo
    @3334momo 4 роки тому

    I think listening to this video with lofi Hip/Hop radio feels so good, it really fits in with the voice!

  • @samisk5841
    @samisk5841 2 роки тому

    Bruh we need more stuff like this on UA-cam

  • @evasiveplant7599
    @evasiveplant7599 3 роки тому

    This was better explained than I thought it would be. Thanks!

  • @jasonbooker3555
    @jasonbooker3555 5 років тому +2

    Very informative!
    Would love to see a video covering mechanics for AIs that need to function in a group/horde. Days Gone as an example.

  • @Rockam
    @Rockam 5 років тому +16

    Amazing analysis! I'm a big fan of your videos, you are motivating me on learning more on AI development :D I think you should consider doing a video analizing the AI on the indie game called "Intruders: Hide and Seek", is not so known, but it has an interesting AI!!

  • @AaditDoshi
    @AaditDoshi 5 років тому +1

    Great video as always! I wish u had given a example of using hirearchecal state machines like u did with fsm.

  • @magnusm4
    @magnusm4 4 роки тому +1

    I've thought of having a state machine with objectives to choose from, but adding in emotional values.
    Say a npc has high fear, then if a job state is given to advance they may become hesitant.
    Or when a group is deciding on an action in a conversation then they also add these emotions into the equation.
    Do they have a high affection for the other npc? Then improve the probability of them agreeing on the other's decision.
    Do they dislike a certain thing? Then decrease the chance of any suggestion involving that.
    Say a soldier is badly hurt, and exhausted with low will.
    A suggestion from an ally says to retreat, retreat has recovery and safety in it.
    The low health and exhaustion makes retreat, guard and take cover positive, and a low will makes positive stronger and negative weaker.
    So the calculation simply says: This new suggestion says retreat, retreat has these values that is positive to our current state. We have low will so we agree more. We agree and join them.
    But if they say advance. Advance has negative values to our current state, our low will makes agreeing lower. We ultimately decide to question it. They say no and agree on advancing.
    We agree but hesitate, hesitate being a status which means we don't follow orders well and rarely perform any new action or goal.
    So if we're covering behind a wall, we cover and don't move. This makes any suggestion with positive values even more positive like retreat so then we're willing to take action.
    But anything with advance or attack will be declined, unless they force us.

    • @getgle
      @getgle 3 роки тому

      Ok but who tf asked

    • @AzraelFPV
      @AzraelFPV Рік тому +1

      @@getgle i hope your year has been bad and when you ask why it's because this comment here

    • @cadrebadre
      @cadrebadre Місяць тому

      This is the definition of Feature Creep. While a hyper advanced behavior system can be implemented in any game, you have to ask yourself what your time horizon is? If you are an indie, is the first game you make worth this amount of time? This is why most modern games with lots of enemies / npcs have regular behavior trees that are not very complex, just take a look at what AI Cyberpunk shipped with. An NPC needs to be able to do its task and be done. An enemy needs to be able to react to the player and seem challenging but not overtly unfair. It's all a balance.

  • @STANNco
    @STANNco 5 років тому +2

    I'd be interesting to delve into ai, like in MGS 5, or just anything where there's seemingly an out of reach command center, sending guards around the map, making decisions. It's something i'm interested in when making my own games

    • @getgle
      @getgle 3 роки тому +2

      MGS5 is so cool just because all the systems work together in ways that I don't think the developers even thought of. Like how if you throw a migrant child at a bear enough times you'll knock out the bear or how you can attach a parachute to a migrant child and then have it fly up and destroy an enemy helicopter. The possibilities seem limitless

  • @TeddyKrimsony
    @TeddyKrimsony 5 років тому +9

    do a breakdown of stalker ai, it has the most unique npc behaviour i have ever seen

  • @Isurvivedthe1990s
    @Isurvivedthe1990s 5 років тому +19

    Half life and fear ai as well as crysis I think have the best ai for my type of playstyle. All hail the Combine!

    • @jacobshirley3457
      @jacobshirley3457 5 років тому

      What's your playstyle? For example, my brother's playstyle was to lower the difficulty so that he could get away with the "guns ablazing, fuck cover" type of style.

  • @SunnyValleyStudio
    @SunnyValleyStudio 5 років тому +2

    Great video. Thank you very much for explaining those nuances between different ai systems. I am pretty sure big studios don't use machine learning very often for ai but are you aware of any successful usage of a learning algorithms as a substitute for a game Ai system?

    • @AIandGames
      @AIandGames  5 років тому +6

      Machine Learning is slowly becoming more prominent, but not in the ways you'd think. ML is being used largely in animation, player modelling and analytics. Either to replicate human behaviour in game (Forza's Drivatar) or to allow us to understand how players are behaving in games (most live service games will have an analyics team using ML). Games like For Honor and Hitman use ML to learn animation controllers so characters move smoothly. Plus there's automated testing, which is still a while away from being able to be used in large AAA titles but teams such as EA's SEED division are exploring that.
      The only recent instances I can think of using ML for an enemy player is Race for the Galaxy (adapted from the board game) and MotoGP 2019. I work as a consultant in the industry and there is a real desire to figure out *how* ML can be used to help developers. Expect to see more of it creeping into big games in the coming years.

    • @SunnyValleyStudio
      @SunnyValleyStudio 5 років тому

      Thank you very much for an extensive answer. It gava me a lot to think about. It seems like the best thing to do is to experiment and maybe idea will come to mind :)

  • @MINERAL-115
    @MINERAL-115 5 років тому +2

    I love these analysis videos, Tommy. Thank you.

  • @nomoremarxistbs7410
    @nomoremarxistbs7410 5 років тому

    Thanks for reminding me to check my schedule.

  • @fioredeutchmark
    @fioredeutchmark 5 років тому +20

    4:17 Did...did that dude just knock himself out?! 😂

    • @AshValen
      @AshValen 5 років тому +15

      That guy knew they were all going to lose, so he threw himself at a distracted Batman, and pretended to get knocked out to both save the bruises, and not lose his job. Promote that guy from henchman to henchmanager

    • @TheALPHA1550
      @TheALPHA1550 4 роки тому

      Why did you type "did" twice?

  • @KhaosEmeraldx
    @KhaosEmeraldx 5 років тому +2

    Informative as always and concise tommy!
    Quick question, do you mind if I ask what you would suggest as a laptop for development sharing? I'm doing my PhD and need a portable machine for conferences.
    Do you think I'd get away with an i5 and 1060? Loving the videos!

  • @abuk95
    @abuk95 5 років тому +2

    thx for video, looking forward to AI in F.E.A.R. video :)
    I am also interested in Unreal Tournament's AI... possible video in future?

  • @TaswcmT
    @TaswcmT 5 років тому +14

    The deeper I get to know AI, the more apparent it becomes that there is no "I" there. It's all "skip logic". That is maybe the most scary part of the world heading towards increased automation. There will never be any real reasoning, just flawed, increasingly complex logic - often puzzled together by people that are as underpaid and overworked as 3D artists.

  • @TheJonesChannel11
    @TheJonesChannel11 5 років тому

    For one of your videos, I want to see you take on Mass Effect and RPG elements. It should be quite a challenge for you.

  • @prairied0g56
    @prairied0g56 4 роки тому

    this video might actually help me pass my midterm

  • @jojolafrite90
    @jojolafrite90 5 років тому +4

    I think some of these systems were more representative of what a conscience is at it's core more than "intuitive" AI that are in development right now.
    I think a real sentience is made of several kind of systems. Some simple, some with a lot of redundancy and complexity, like deep neural network-using source codes.

  • @superlukey3
    @superlukey3 5 років тому +2

    I've seen a few of your videos that have covered FSMs and behavior trees in the past, and I'll be honest - I don't quite understand in what way they are different. It seems to me as though a behavior tree is just an extremely complicated FSM with enough different paths and branches that it becomes too difficult to draw out a full graph very easily. Is there any chance you know of a video or writing, or plan one yourself, that discusses in a very concrete way the exact differences in implementation, capabilities, etc. of finite state machines and behavior trees? Sorry if you've already made a video on the subject - if you have I must have missed it!

    • @AIandGames
      @AIandGames  5 років тому +8

      There are a couple of key distinctions:
      1) FSMs are typically fully connected cyclic graphs. You can transition from state A, to B, to C, to E then back to A. You're always cycling between states and never terminate the logic of the FSM. It's always either in an active state or transitioning between them. Meanwhile Behaviour trees are acyclic. You run the logic from the top of the tree to the bottom, once you're done, you start all over again from the top.
      2) Behaviour trees don't encode conditions for transition logic unless it's a sequence or selector node. Selectors dictate which one of X sub-trees to execute, and sequences dictate several nodes are executed in a fixed order. Other than that it's a top-down-left-to-right execution model we typically see in the likes of binary trees. That might sound more complicated, but from a computer science perspective, it's both a lot simpler and a more well-established paradigm.
      3) Reacting to change is a lot easier. If the game world triggers an event that could force major change for the AI, the BT simply restarts the tree from the top. Whereas the FSM simply reacts to the input - but only if the current state cares about it. It's a lot harder to redesign numerous FSM states to react to one specific behaviour, while a BT just resets the tree and follows the appropriate logic.
      4) Designing BT's is a LOT easier. Speaking from experience - and certainly speaking with a lot of other developers - BT's are great because you can figure out in the scope of your AI design how certain behaviours will fit and where they need to sit in the space of all possible circumstances. FSMs are a lot harder as you need to know what states will transition into that new behaviour, which ones it can transition out of and the weird circumstances that will lead you to accidentally get into that new behaviour. This comes back to point #1. In a BT if you wind up in a given behaviour (say node X), you can read the tree from top-down to figure out how you got there. In a FSM it might be due to 10 minutes of transition from states A,B,F,R,D,A,B,C,D,A,D,A then X. There might be some very specific issues somewhere in that chain of states that led you to enterting state X and you - as a designer - didn't want that to happen. That means you need to write the transition logic to be a lot more complex.
      I have had requests to do a more specific episode about 'choosing the right AI for your game' and that might be an AI 101 episode in the future. But before I do that, I want to cover GOAP and HTN planning as well as utility AI then could bring all of those together in a compare/contrast video, which I think could help a lot of devs in deciding what they want to do.

    • @superlukey3
      @superlukey3 5 років тому +2

      @@AIandGames Oh, that makes much more sense. I think the key I was missing was the top-down execution - it didn't quite solidify in my mind that behavior trees were the same type of tree as search trees and decision trees. Thanks a lot!

    • @tyridge7714
      @tyridge7714 4 роки тому

      @@AIandGames is there a discord or anywhere where we can contact you with any technical questions ? I'm a full time game developer running into some design issues with behavior trees and I'd love to pick your brain and experience in the field.

  • @bohba13
    @bohba13 5 років тому +1

    Nice to see you in my sub feed again. How's life?

  • @sneedle252
    @sneedle252 Рік тому

    Would love a vid on STALKER: GAMMA.

  • @chips989
    @chips989 3 роки тому

    "Pac-Man and Ms. Pac-Man"
    What an exhaustive list! lol

  • @SkyYurt
    @SkyYurt 5 років тому +1

    great video as always!

  • @puksna
    @puksna 5 років тому +1

    If the FSM system has states, machines and transitions, whether the transition functions from one state to another should be in the state or should be completely independent of the state. What are the advantages and disadvantages of each approach? I understand the state as one that does not know about other states. The logic that determines the transition should be within the machine itself and not the state. In this way, it is possible to implement different types (classes) of transition (hardcoded, decision tree, fuzzy logic, utility functions...) independently of the state. Does this approach have certain defects?

    • @AIandGames
      @AIandGames  5 років тому +1

      Typically you build transition logic into the states themselves, otherwise if you build it elsewhere in the FSM it detracts from executing the state logic, since the FSM is worried about whether it needs to force a transition. Typically the state will tell the FSM to transition to another state. It means that the logic is contained within the state and makes it a little cleaner and easier to debug, but still it becomes convoluted in the long run anyway.

  • @hungryhedgehog4201
    @hungryhedgehog4201 4 роки тому +1

    FSMs are cool but sometimes the AI gets self aware and you never hear the end of it.

  • @MrCantStopTheRobot
    @MrCantStopTheRobot Рік тому

    I've heard multiple videos say it's impossible for these FSM entities to move and shoot simultaneously. Why can't there be a single event whose definition involves coordinates changing and projectiles spawning? Is there a logical restriction to handling only one argument type per event?

  • @Galomortalbr
    @Galomortalbr 2 роки тому +1

    Honestly Half Life 1 AI is still better than most AIs made nowdays, it's not as good as F.E.A.R but still better than the brainless bots we have around.

  • @thecombinesoldier6611
    @thecombinesoldier6611 5 років тому +2

    I see Half Life in titile and I come and btw HL3 Confirmed

  • @SolidTime
    @SolidTime 5 років тому +1

    What's with the desert eagle and M4? They weren't in HL, only CS.

    • @batmangovno
      @batmangovno 5 років тому +4

      M4 replaces the MP5 with the High Resolution pack (released with Blue Shift in 2001) and the Deagle-type gun is part of Opposing Force.

  • @mitigatedrisk4264
    @mitigatedrisk4264 5 років тому +2

    First pierson shewters.

  • @argir5849
    @argir5849 5 років тому

    It's nice seeing the comment section before being flooded by "here from X youtuber" comments xD

  • @Nickle-mu7ws
    @Nickle-mu7ws 5 років тому +1

    11/10 accent

  • @purrspctiv
    @purrspctiv 5 років тому

    Hell yeah

  • @brannanz
    @brannanz 5 років тому

    ive got the sierra disc of hl

  • @REXanadu
    @REXanadu 5 років тому

    For those interested in the new tutorial channel mentioned at the end, here's a link:
    ua-cam.com/channels/jG7y5Iw4TLHcK6ckuqUj_A.html

  • @poundlandpatriot4874
    @poundlandpatriot4874 5 років тому +5

    Here from 3kliksphilip

  • @decoyminoy
    @decoyminoy 4 роки тому

    Please do the AI of Escape From Tarkov, The ai in that game seem like they are actual players at times and its incredible

  • @brannanz
    @brannanz 5 років тому

    monster_scientist, Classic.

  • @cheddars2
    @cheddars2 4 роки тому

    your aigamedev links are broken.

  • @casedistorted
    @casedistorted 5 років тому +1

    I swear he said 1998 Shitter.. lol

  • @magnuscritikaleak5045
    @magnuscritikaleak5045 4 роки тому

    Conditions.

  • @Noldy__
    @Noldy__ 4 роки тому

    Where does one even start learning this kind of stuff? Where would you send a complete noob like me to begin?

  • @moguldamongrel3054
    @moguldamongrel3054 5 років тому +1

    why is it called ai when its just scripts set to act during certain condition responses. the bots themselves have no intelligence. its like an answering machine, auto recording a message. is the answering machine now ”artificially intelligent”.

    • @SophieJMore
      @SophieJMore 5 років тому +1

      It's just easier to call it AI

    • @moguldamongrel3054
      @moguldamongrel3054 5 років тому +1

      A Leo X but their not.

    • @Gmadador
      @Gmadador 5 років тому

      Then what would you consider actual A.I in video games

    • @AIandGames
      @AIandGames  5 років тому +4

      An answering machine simply executes an action when told to do so. It doesn't have any agency.
      Artificial Intelligence requires two key things:
      1) It is autonomous, so it works without human intervention.
      2) It makes the 'best' decision it can given the information it has.
      Does that make it equivalent to human intelligence? Nope. But then we humans have difficulty agreeing on what that even means.

    • @moguldamongrel3054
      @moguldamongrel3054 5 років тому +1

      AI and Games i was specifically referring to the half life bot scripts for various npcs. Which do exactly as you stated, they respond to conditions set forth in their programming much like an answering machine. ie player footsteps trigger assassin bot to search out source. they dont actually have intelligence of any kind. Hence they should not be classified as ai. Unless im to classify my answering machine as ai.
      Thanks though for the text book answer on general ai.
      Although clickbait title as an explanation would suffice lol.

  • @thanosdevito
    @thanosdevito 4 роки тому

    sheduole

  • @SophiaWoessner
    @SophiaWoessner 2 роки тому

    Took me nine minutes to realize he's scottish

  • @mazimadu
    @mazimadu 5 років тому +3

    So, what about Half Life 2?

    • @ileryon4019
      @ileryon4019 5 років тому +3

      Good ai, but valve thought they were too hard to fight so they nerfed it to the ground.. still a good ai but hl1 Is prop better

    • @mazimadu
      @mazimadu 5 років тому

      @@ileryon4019 I was referring to the technique not the execution

    • @ileryon4019
      @ileryon4019 5 років тому

      @@mazimadu okay

    • @dracmeister
      @dracmeister 5 років тому +7

      Better AI than HL1 but the level design isn't suited for it.

    • @mazimadu
      @mazimadu 5 років тому

      @@dracmeister Oh, thanks!

  • @MeHaveDonuts
    @MeHaveDonuts Рік тому

    "Tried playing gta 5 and I hit a female pedestrian. Now her boyfriend attacks me each time I log on, then hires gangs to start up businesses and bankrupt the stock industry all so it could bribe the cops into keeping me on the wanted list permanently...fix this bug Rockstar"
    Lol jokes aside yeah complicated AI in games is not possible yet as not only would there be infinite issues that come up, most pcs can't handle the amount of data that needs to be processed...yet.

  • @aryangod2003
    @aryangod2003 2 роки тому

    Game AI is not real AI. It is smoke and mirrors.

  • @alexlokanin3312
    @alexlokanin3312 5 років тому

    please keep being scottish

  • @davymachinegun5130
    @davymachinegun5130 4 роки тому +1

    "Dated."
    That's when you shut the video off.

    • @getgle
      @getgle 3 роки тому

      Dilate

  • @DefinitelyAPotato
    @DefinitelyAPotato 4 роки тому

    It's just Wolfenstein, not Wolfenschtein ;)