Tips & Tricks For Simple But Smart AI

Sdílet
Vložit
  • čas přidán 22. 08. 2024

Komentáře • 91

  • @SomeGuy-my7en
    @SomeGuy-my7en Před 4 lety +53

    I've always wondered how enemy AI avoids obstacles. Thanks a lot!

    • @LycheeGameLabs
      @LycheeGameLabs  Před 4 lety +3

      You're welcome

    • @SomeGuy-my7en
      @SomeGuy-my7en Před 4 lety

      @Patch Quest
      By the way is your game on Steam or is it still in the works? If so then I'll consider checking it out.

    • @LycheeGameLabs
      @LycheeGameLabs  Před 4 lety +3

      @@SomeGuy-my7en It's coming to Steam in 2020, although for now you can download a standalone alpha from the main site - lycheelabs.net/

  • @jochenpanjaer980
    @jochenpanjaer980 Před 4 lety +50

    This was really genious! Great alternative to A* pathfinding in situations like these.

  • @weichen1
    @weichen1 Před 3 lety +11

    As an AI engineer, I have to say this video is brilliant!

  • @TheCrewExpendable
    @TheCrewExpendable Před 4 lety +15

    Great editing! It’s crazy how good your videos have gotten.

  • @colcoction6072
    @colcoction6072 Před 4 lety +12

    Great video! Nice presentation of some really clever solutions.

  • @otakutherapist
    @otakutherapist Před 3 lety +1

    I can't believe how well made this video is. Just discovered your channel and it's awesome for someone like me who's in the early stage of game development.

  • @YuriNoirProductions
    @YuriNoirProductions Před 4 lety +11

    great content. love how this is actual game design mixed with coding :) great work

  • @elizabethtana8862
    @elizabethtana8862 Před 4 lety +2

    Really appreciate this content, and it has me thinking. You mentioned tweaking and expanding, and the two things it gets me thinking about are 1) UI/UX for working these weights out, and 2) using cooldowns rather than applying weights. This has the added bonus of limiting spamming in a lot more situations, and an ability on cooldown can have a 0 weight pretty easy. The springs idea as a core behavior is really clever though, and I really appreciate the examples.

    • @proclarushtaonasat
      @proclarushtaonasat Před 3 lety

      or how about, positive/negative Feedback? Like, have both a weight and cooldown System, but have the weight be influenced by the successrate of previous attempts. Like, if an enemy uses an attack, and it manages to deal you Damage, it will feel success, and try to use that attack more, but if it Fails, it will feel less encouraged to do so.
      It may not work for every game, but at least in boss battles, its Always so frustrating, when the solution is simply doing the same Thing over and over, and the boss keeps falling for it.
      In the first pokemon games, if you use bulbasaur, the Trainers in the grass gym would constantly spam Poison powder (a non-damaging move, that inflicts Poison), despite the fact, that as a grass/Poison type bulbasaur cant get the Poison-Status, just because Poison type does 1x Damage, and their other plant type attacks do only 1/4 Damage. And since back then, the cpu has infinite AP for each move, theyd never stop using it, even though it will never work.
      Compare that to, for example, the hinox from zelda botw: you can shoot an arrow in his eye to stun him, but after you do that once, they will cover their eyes with their Hands, when they see you pull out a bow, cause they learned.

    • @user-mu2ex8bx2t
      @user-mu2ex8bx2t Před 3 lety

      @@proclarushtaonasat cool idea

  • @kornel8801
    @kornel8801 Před 4 lety +5

    Great tips and great system, thank you for making the video!

  • @Atenvardo
    @Atenvardo Před 2 lety +1

    Would love to see another video some almost 2 years later on where the AI stands up today, this video really helped me with my game dev journey!

  • @sirreginaldfishingtonxvii6149

    Man, that's really cool!
    ...Now I just need to learn how to program that.

  • @arsenbabaev1022
    @arsenbabaev1022 Před 3 lety +1

    your content is gold I watched like 5 vids in a row and got valuable info from all of them, ill get to modern content eventually

  • @renankvieira
    @renankvieira Před 4 lety +18

    Amazing and creative solutions, specially the spring system.
    One question: how and where is the spring strength set in your implementation?
    Thanks a lot for this.

    • @LycheeGameLabs
      @LycheeGameLabs  Před 4 lety +4

      Each 'spring' is really just a function that takes in two characters, calculates the distance/direction between them, and returns a 3D vector based on this. The details of this function determine the spring strength. These vectors are then summed together to get the final intention. From 3:15 you can see some examples of how to write these functions (they'll need some trial and error tweaking to fit into your own game).

  • @GhostOnTheHalfShell
    @GhostOnTheHalfShell Před 3 lety

    very nice. For concave features it seems like a quick calculation of the side an target is on can be used to add a repeller to the “inside” or depression. This would pop the ai out of the dead end.

  • @happysnake3702
    @happysnake3702 Před 4 lety +5

    This was brilliant and so useful! Will be trying something like this when I next do a game jam :D Thank you!

  • @serious07
    @serious07 Před 4 lety +1

    Simple and flexible system of decisions, I'm like it a lot concept that you use, a nice AI behavior system! I'm will try to do it a little bit modular with interfaces and AI state machine in my next game.

  • @Skizmo
    @Skizmo Před 3 lety

    I just want to say your videos are some of the best game dev videos I have seen! Great job!

  • @derekw8039
    @derekw8039 Před 3 lety +3

    8:43 I see what you did there :)

  • @123TeeMee
    @123TeeMee Před 4 lety +2

    Regarding part 3, including type matchups, and designing moves to be roughly equal in power, would be a good addition to weights as you described

    • @123TeeMee
      @123TeeMee Před 4 lety +1

      more generally than a rock paper scissors system, each move should be made situational, perhaps situational based on time, so a strong move has a long cooldown and in that time it is weaker and other weak moves are preferable

    • @LycheeGameLabs
      @LycheeGameLabs  Před 4 lety +3

      @@123TeeMee Those are definitely features you could add to a system like this. Good suggestions!

  • @Drawoon
    @Drawoon Před 3 lety

    The patch quest public beta does have concave shapes. I believe two corals spawned diagonally from each other and a monster tried to get through them. It was pretty funny.

  • @LEGnewTube
    @LEGnewTube Před 3 lety +1

    Those are really cool programming tricks!

  • @JonathanbmillerZIG
    @JonathanbmillerZIG Před 3 lety +1

    Thank you for this! This saved me a good bit of time.

  • @HansLemurson
    @HansLemurson Před 3 lety +2

    Weight down the score
    Adjust towards the floor
    Choose strategy for dinosaur

  • @theinternet6313
    @theinternet6313 Před 3 lety

    I just came from your "Tips For Making Games Fast" video and I'm convinced AI is humanity's soft barrier

  • @BougGroug
    @BougGroug Před 3 lety +6

    Can someone explain to me how the inverse cube thing works?

    • @kieraleahy6795
      @kieraleahy6795 Před 3 lety +4

      In real physics as energy spreads out it's strength reduces by the inverse square, for example if you're lighting an object and you double the distance between the light source and the object the lighting level will quarter (one half squared is one quarter). But if you instead were to create a world where light fades by an inverse cube law moving a object twice as far away from the source would reduce the lighting by one eighth (one half cubed), essentially the inverse cube is more dependent on the distance than the inverse square so the effect of the light source "scrunches up". In the game example in the video the force of the spring is made the depend more on the distance so the force is too "scrunched up" to effect further away objects any appreciable amount.
      I'm sure someone else could explain in less words but that's the gist.

    • @BougGroug
      @BougGroug Před 3 lety +1

      @@kieraleahy6795 Thank for your response, but I'm still having difficulty understanding the concept (especially the math part). Would you know any video or article that explains it in more detail?

    • @ChubbiestLamb6
      @ChubbiestLamb6 Před 3 lety +2

      @@BougGroug
      Squaring a number is when you multiply it with itself. 2 squared is 2 * 2 which is 4. Cubing something is the same, but 3 times instead of twice. So 2 * 2 * 2 which is 8.
      An inverse of a number is when you flip its numerator (the top number of a fraction) and its denominator (the bottom number of a fraction). Since all whole numbers can be written as fractions with a denominator of one (e.g. 2 is the same as 2/1), you can also put a number under 1 to find its inverse (1/2).
      So the inverse cube of a number just combines these two ideas. The inverse cube of 2 is 1/8. To generalize it, the inverse cube of some variable X is 1/(X*X*X). For the purpose of the spring mechanic described in the video, X is the distance between the enemy and the player.
      Now, for why this works well:
      As the denominator of a fraction gets larger compared to the numerator, the value decreases (1/2 is much bigger than 1/8, which is bigger than 1/32, etc). So in our code, the larger the distance X between player and enemy, the larger the denominator will be in our inverse square. Which means the farther away the player is, the less the enemy is pulled towards them. This diminishing effect is greater and greater the father the distance, because the cubing effect multiplies its size faster than the distance grows as you get farther away. It's exactly how gravity works in real life. The sun has tremendous gravity, enough to keep the whole earth spinning around it. But we dont get sucked off of earth towards the sun, because the sun's gravity is diminished very quickly as it "spreads out" to all the 3d space in between it and the earth. If we flew a space ship closer, though, the gravity would rapidly grow stronger and stronger until it was irresistable.
      Hopefully this helps! (Assuming you haven't figured it out yet)

    • @BougGroug
      @BougGroug Před 3 lety

      @@ChubbiestLamb6 Thank you so much! That's exactly what I needed!

  • @spaceowl5957
    @spaceowl5957 Před 3 lety

    This video is so cool! Your solutions are really smart and you explain and simplify them brilliantly. Very satisfying watch.
    It would be awesome if you could give more insight into how you came up with these ideas.

  • @KalechippsDev
    @KalechippsDev Před 4 lety

    crazy good video. happy to have found your channel

  • @loszhor
    @loszhor Před 3 lety +1

    Thank you for the information.

  • @theothetorch8016
    @theothetorch8016 Před 3 lety +1

    My life saver.

  • @stickzman
    @stickzman Před 3 lety

    Look out Mark Brown, there's a new kid on the block!

  • @glorytoarstotzka330
    @glorytoarstotzka330 Před 3 lety

    even after 1 year, this is gold

  • @maddylim3982
    @maddylim3982 Před 3 lety +1

    The spring system is so amazing, but I am still wondering how to set the spring strength. Your reply to Renan Viera didn't quite make sense. Thanks in advance!

    • @LycheeGameLabs
      @LycheeGameLabs  Před 3 lety

      It's just trial and error until they act how you want

  • @daviddecicco1325
    @daviddecicco1325 Před 4 lety

    Kudos. This is a genius system design. At least in my opinion

  • @thanhpt1711
    @thanhpt1711 Před 4 lety +1

    subscribed :) thanks for sharing

  • @kerbanius9215
    @kerbanius9215 Před 3 lety

    For the defence sprint, is it not more efficient to use a trigger around the enemy to detect the incoming bullets? Seems more efficient than having all enemies loop through the bullets in the scene every frame. Really curious what approach is more efficient.

  • @egorexw3612
    @egorexw3612 Před 2 lety

    Brilliant methods, but i wonder how you make enemies stay away from border. Thanks in advance

  • @lashwrithe01
    @lashwrithe01 Před 3 lety

    Great ideas!

  • @rogercruz1547
    @rogercruz1547 Před 4 lety

    6:00 bad example, because 90 degrees you can shoot directly! it will bounce and hit the target just fine hehehehe

    • @pulpil10
      @pulpil10 Před 4 lety

      if the bullet bounced, it could get reflected back down

    • @rogercruz1547
      @rogercruz1547 Před 4 lety

      @@pulpil10 Not when corridors have the same width

  • @grantm5495
    @grantm5495 Před 3 lety +1

    very good video, but I have a question
    I made a very similar system to this for my game, but I found an issue when an enemy has many different targets. sometimes 2+ targets will "pull" the enemy toward themselves, but if the targets are on opposite sides on the enemy they enter a kind of tug of war and cancel each other out, causing the enemy to get stuck in between. do you know a solution to this?

    • @LycheeGameLabs
      @LycheeGameLabs  Před 3 lety +2

      You could make the enemy swap between the targets, so it only has 1 target at any time

  • @Taro4012ITG
    @Taro4012ITG Před 3 lety

    What's the song in the summary? It's so familiar but I can't quite put my finger on it!

  • @dragonsamurai559
    @dragonsamurai559 Před 3 lety +2

    Question: does this apply to a game with a 3D interface?

    • @ChubbiestLamb6
      @ChubbiestLamb6 Před 3 lety +4

      I don't see why it wouldn't work. Your characters probably spend most of their time navigating a 2D plane anyway (the ground), their bodies just occupy more dimensions while they do it.
      If your game involves flying or being underwater or floating in space or whatever, you could just add more vectors along the extra dimension and add them up with the others.

  • @retrodad9390
    @retrodad9390 Před 3 lety

    Clever!

  • @Norbingel
    @Norbingel Před 4 lety

    How's the performance on looping through every bullet per frame? Or do you just make sure there aren't too many on screen at a time?

    • @LycheeGameLabs
      @LycheeGameLabs  Před 4 lety

      If your scene has huge amounts of objects, you'll need some kind of space-partitioning system to prune distant checks

  • @littlegreen4899
    @littlegreen4899 Před 2 lety

    Hey so any body a solution to put all of evaluated actions into the list as Iam stuck on that part because I won’t let directly put them in for some reason I can’t just go list

  • @rafbi4874
    @rafbi4874 Před 4 lety

    Very nice

  • @littlegreen4899
    @littlegreen4899 Před 2 lety

    How do I chose the highest score

  • @resrrasg8881
    @resrrasg8881 Před 3 lety

    It woud be easy to make it look like trick shot?

  • @jgbeu
    @jgbeu Před 3 lety

    Is nobody going to comment on that super solid joke he just snuck in there? Boom Boom acka lacka lacka boom! czcams.com/video/zYKupOsaJmk/video.html

  • @gentelmen...5450
    @gentelmen...5450 Před 3 lety

    11:47 "LİTTLE"

  • @AlgaeNymph
    @AlgaeNymph Před 4 lety

    I'm planing out a grid-based 4X; what about this AI would need to change, and what would stay the same?

  • @TMtheScratcher
    @TMtheScratcher Před 3 lety +1

    Very nice! Especially the spring system. However, I disagree with the part of shooting trough walls vs wall bounce. Changing this has much more effects than saving time and computation power:
    1. It is easy to identify bullets flying direct towards you, but much harder to identify these when they wall-bounce (especially in cases where mny bullets are around).
    2. it does not have the same effect. In my opinion such an AI looks stupid and the game dev lazy. The wall bounce requires more effort, but this effort is not invisible. Also it makes the AI really look intelligent (it reminds me at the tanks in the wii play game) and thechnically it is more intelligent than the simple AI.
    3. limit yourself to simplify code and situtions also limits the features. Adding wall bounce alone adds the variable of "how often does it bounce off?", which allows to add a variety of bullets/enemies just based on this single feature. Additional features may even interact with this, like bullets making sounds if the bounce off and some entity of the game then interacts with these sounds enabling many new possiblities for level design.

  • @digivagrant
    @digivagrant Před 4 lety +1

    Is this applicable to 3rd Person Shooters?

    • @5minutemovies977
      @5minutemovies977 Před 4 lety +1

      I see no reason why not. But you have to consider that in a 3D space, you would handle the vectors to move your characters differently since they can be on different levels. You may want to use some kind of deeper pathfinding I suppose for a 3D game

  • @5minutemovies977
    @5minutemovies977 Před 4 lety

    I swear if you use any music from Chrono Trigger again, I'm gonna cry !

  • @mateuszpatua3016
    @mateuszpatua3016 Před 3 lety

    CLEVER :o

  • @TK-sr2hz
    @TK-sr2hz Před 4 lety

    Bro what version of unity are you using...I see those "var"

    • @stw7120
      @stw7120 Před 3 lety

      It's pseudocode. He literally says it 4:20

  • @locusruizlopez5997
    @locusruizlopez5997 Před 3 lety

    usefull

  • @batomow
    @batomow Před 3 lety

    Very cool but calling complex operations every frame is... a bit much.

    • @Wylie288
      @Wylie288 Před 2 lety

      it doesn't *have* to be every frame. Just run the calculation every time the enemy is looking to attack

  • @sukhmandersingh4306
    @sukhmandersingh4306 Před 3 lety

    Pls not gerudo valley i'll cry

  • @d.l.7416
    @d.l.7416 Před 4 lety +1

    FIRST
    again again

  • @tibegamer7360
    @tibegamer7360 Před 3 lety

    There is no AI at all in this

  • @danieloization
    @danieloization Před 4 lety +1

    There are hundreds of thousands of indie games out there. How many of these succeeded? Almost none... So what does that tell us? It tells us that the programming is the easy part, and that the psychology behind what makes a game fun is the hard part.
    If you want to cater to beginner programmers that's fine though. Do you have any tips for other CZcamsrs talking about game psychology?