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.
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.
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.
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.
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).
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.
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.
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
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.
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.
@@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?
@@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)
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.
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!
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.
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?
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.
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
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.
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
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?
I've always wondered how enemy AI avoids obstacles. Thanks a lot!
You're welcome
@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.
@@SomeGuy-my7en It's coming to Steam in 2020, although for now you can download a standalone alpha from the main site - lycheelabs.net/
This was really genious! Great alternative to A* pathfinding in situations like these.
Thanks Jochen
As an AI engineer, I have to say this video is brilliant!
Great editing! It’s crazy how good your videos have gotten.
Thanks, I'm always looking to improve
Great video! Nice presentation of some really clever solutions.
Thanks Colin
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.
great content. love how this is actual game design mixed with coding :) great work
Thanks!
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.
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.
@@proclarushtaonasat cool idea
Great tips and great system, thank you for making the video!
You're welcome Kornel
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!
Man, that's really cool!
...Now I just need to learn how to program that.
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
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.
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).
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.
This was brilliant and so useful! Will be trying something like this when I next do a game jam :D Thank you!
You're welcome Happy Snake
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.
I just want to say your videos are some of the best game dev videos I have seen! Great job!
8:43 I see what you did there :)
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
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
@@123TeeMee Those are definitely features you could add to a system like this. Good suggestions!
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.
Those are really cool programming tricks!
Thank you for this! This saved me a good bit of time.
Weight down the score
Adjust towards the floor
Choose strategy for dinosaur
I just came from your "Tips For Making Games Fast" video and I'm convinced AI is humanity's soft barrier
Can someone explain to me how the inverse cube thing works?
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.
@@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?
@@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)
@@ChubbiestLamb6 Thank you so much! That's exactly what I needed!
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.
crazy good video. happy to have found your channel
Thank you for the information.
My life saver.
Look out Mark Brown, there's a new kid on the block!
even after 1 year, this is gold
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!
It's just trial and error until they act how you want
Kudos. This is a genius system design. At least in my opinion
subscribed :) thanks for sharing
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.
Brilliant methods, but i wonder how you make enemies stay away from border. Thanks in advance
Great ideas!
6:00 bad example, because 90 degrees you can shoot directly! it will bounce and hit the target just fine hehehehe
if the bullet bounced, it could get reflected back down
@@pulpil10 Not when corridors have the same width
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?
You could make the enemy swap between the targets, so it only has 1 target at any time
What's the song in the summary? It's so familiar but I can't quite put my finger on it!
Question: does this apply to a game with a 3D interface?
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.
Clever!
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?
If your scene has huge amounts of objects, you'll need some kind of space-partitioning system to prune distant checks
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
Nvm I solved it by looking at documentation
Very nice
How do I chose the highest score
It woud be easy to make it look like trick shot?
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
11:47 "LİTTLE"
I'm planing out a grid-based 4X; what about this AI would need to change, and what would stay the same?
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.
Is this applicable to 3rd Person Shooters?
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
I swear if you use any music from Chrono Trigger again, I'm gonna cry !
CLEVER :o
Bro what version of unity are you using...I see those "var"
It's pseudocode. He literally says it 4:20
usefull
Very cool but calling complex operations every frame is... a bit much.
it doesn't *have* to be every frame. Just run the calculation every time the enemy is looking to attack
Pls not gerudo valley i'll cry
FIRST
again again
There is no AI at all in this
What you mean
That is ai
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?