Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need Experienced: How to make enemy AI?
- Informinity
-
100+ posts
Need Experienced: How to make enemy AI?
Well, when it comes to scripting on scratch I am pretty good, except for AI and pen.
Yeah, AI.
Not sure how that would work with detecting walls and choosing the best route, when to approach the player to attack or hide, nor do I know how to not have all enemies clump together because they will take the same exact routes.
Anyone have experience with AI on scratch and want to pour out some of their knowledge into my cup?
Thanks
Yeah, AI.
Not sure how that would work with detecting walls and choosing the best route, when to approach the player to attack or hide, nor do I know how to not have all enemies clump together because they will take the same exact routes.
Anyone have experience with AI on scratch and want to pour out some of their knowledge into my cup?
Thanks
- zp100
-
100+ posts
Need Experienced: How to make enemy AI?
I haven't had much experience with AI (the best I did was mindless zombies that always walk straight toward you
), but I'm really good with scripts and I would love to help. What kind of AI do you need, exactly?

- whyamialive
-
1 post
Need Experienced: How to make enemy AI?
I need an AI to do my homework.
- zp100
-
100+ posts
Need Experienced: How to make enemy AI?
Just, any kind of AI? Well, then there's lots of options. You could make a sprite that constantly chases you. Or, it could chase you most of the time, unless you're bigger or have a power-up or something. A chasing script would be like this: I need an AI to do my homework.
And, a running away script would be like this:
Put together, it would be like this:
There's hundreds of ways you could make AI. If you search Scratch for “AI” then you'll probably get a bunch of results.
- Laddie12
-
100+ posts
Need Experienced: How to make enemy AI?
What is your project like?
Does it use typical Scratch stuff like
If you are having trouble answering this question, you probably just use the Scratch-specific method
The reason I am asking this is so that I can tell which approach to AI you can use.
Does it use typical Scratch stuff like
or does it display data differently?
If you are having trouble answering this question, you probably just use the Scratch-specific method
The reason I am asking this is so that I can tell which approach to AI you can use.
- Informinity
-
100+ posts
Need Experienced: How to make enemy AI?
What is your project like?
Does it use typical Scratch stuff likeor does it display data differently?
If you are having trouble answering this question, you probably just use the Scratch-specific method
The reason I am asking this is so that I can tell which approach to AI you can use.
Well… its this - https://scratch.mit.edu/projects/62583868/
I need to figure out how to make a very very complex enemy AI that does not cause much lag and still adds some challenge to defeating them.
- zp100
-
100+ posts
Need Experienced: How to make enemy AI?
How about…It circles around you and fires at you, and backs away if you get close. I'm not good enough at trigonometry to make circling scripts, though. 

- Studio42
-
500+ posts
Need Experienced: How to make enemy AI?
Well in ROTMG the regular gods aren't too hard, they just deal a decent chunk of damage if you are 0/8. Maybe model the AI off them? You could have a script that chases the player with some extra random movement. If you are going to have the dungeons, then you just have to program the phases of the bosses and model them from in ROTMG.
I think that a charge type thing like Limon has would be cool, as well as the medusa bombs.
I think that a charge type thing like Limon has would be cool, as well as the medusa bombs.
- Informinity
-
100+ posts
Need Experienced: How to make enemy AI?
Well in ROTMG the regular gods aren't too hard, they just deal a decent chunk of damage if you are 0/8. Maybe model the AI off them? You could have a script that chases the player with some extra random movement. If you are going to have the dungeons, then you just have to program the phases of the bosses and model them from in ROTMG.
I think that a charge type thing like Limon has would be cool, as well as the medusa bombs.
Pathfinding would be my biggest problem. I should be able to make it so some enemies can charge and stuff, but making it so they know where walls are and how to get around them may be confusing.
- Laddie12
-
100+ posts
Need Experienced: How to make enemy AI?
Set up data points with a list of walls (many ways to do this, there is not way to make this fun) and then make calculations based on those walls. If you don't want to manually enter wall points, you could set up walls with an algorithm or you could do it with invisible sprites (slow).
You will have to brave the AI calculations yourself since I have no idea what you specifically want. I would advise using google to look for some standard AI tutorials.
You will have to brave the AI calculations yourself since I have no idea what you specifically want. I would advise using google to look for some standard AI tutorials.
Last edited by Laddie12 (May 2, 2016 18:22:39)
- Informinity
-
100+ posts
Need Experienced: How to make enemy AI?
Set up data points with a list of walls (many ways to do this, there is not way to make this fun) and then make calculations based on those walls. If you don't want to manually enter wall points, you could set up walls with an algorithm or you could do it with invisible sprites (slow).
You will have to brave the AI calculations yourself since I have no idea what you specifically want. I would advise using google to look for some standard AI tutorials.
Alright, thanks for the tips. I will try making a separate AI outside of the game first so I have an idea of what to do actually in the game.
- Laddie12
-
100+ posts
Need Experienced: How to make enemy AI?
Great ideaSet up data points with a list of walls (many ways to do this, there is not way to make this fun) and then make calculations based on those walls. If you don't want to manually enter wall points, you could set up walls with an algorithm or you could do it with invisible sprites (slow).
You will have to brave the AI calculations yourself since I have no idea what you specifically want. I would advise using google to look for some standard AI tutorials.
Alright, thanks for the tips. I will try making a separate AI outside of the game first so I have an idea of what to do actually in the game.

Previous experience ALWAYS helps when doing this kind of thing
- piddlepants200
-
3 posts
Need Experienced: How to make enemy AI?
I need help to make Pac-Man and I need my ghosts to not be able to pass through walls but still have an AI
- YeeSweetMoom64
-
6 posts
Need Experienced: How to make enemy AI?
I need a AI with its own screen but you cant see it.
- YeeSweetMoom64
-
6 posts
Need Experienced: How to make enemy AI?
I meant its movement is not relative to the screen.
- deck26
-
1000+ posts
Need Experienced: How to make enemy AI?
Please create your own new topic. I meant its movement is not relative to the screen.
- Justanotification
-
1 post
Need Experienced: How to make enemy AI?
does anybody know how to do enemy ai for a 2d platformer
- FlamingHamburger
-
5 posts
Need Experienced: How to make enemy AI?
How about…It circles around you and fires at you, and backs away if you get close. I'm not good enough at trigonometry to make circling scripts, though.
no need to make a circling script! all you have to do is go into the enemy sprite costume design, select all of the enemy, make sure it is in VECTOR, not BITMAP! Then drag it as far as you can off the edge and write this code:
- SuperInky
-
44 posts
Need Experienced: How to make enemy AI?
You could try starting a flood fill starting from the target (every dot flood fill should detect the distance between itself and the target), that goes around until it finds the enemy. Once this flood fill ends, it makes the enemy follow the dots that are closest to the target, in a progressive manner.
You could also try doing flood fill in a grid, and using almost the same methods, but making those dots follow or snap to the grid, therefore reducing lag potentially by a lot. This'd help a lot for grid-based games, like Pacman (though I wouldn't recommend using this type of AI in that game).
As to achieve this, I'm not exactly sure how, but you could use lists to store all the dots' positions and their distances to the target. You can also find this method achieved successfully in some projects to guide yourself.
There is an example of a reversefloodfill-based project in a grid: https://scratch.mit.edu/projects/281526265/
Hope this helps.
EDIT: my bad, didn't read the entire post. As to make the enemies not be crowded, you could make them have different targets, for example, one trying to follow the player from behind instead, or a random value that makes them target at other distances. You could also add a range for them to follow you and to stop following, if it's from any help.
You could also try doing flood fill in a grid, and using almost the same methods, but making those dots follow or snap to the grid, therefore reducing lag potentially by a lot. This'd help a lot for grid-based games, like Pacman (though I wouldn't recommend using this type of AI in that game).
As to achieve this, I'm not exactly sure how, but you could use lists to store all the dots' positions and their distances to the target. You can also find this method achieved successfully in some projects to guide yourself.
There is an example of a reversefloodfill-based project in a grid: https://scratch.mit.edu/projects/281526265/
Hope this helps.
EDIT: my bad, didn't read the entire post. As to make the enemies not be crowded, you could make them have different targets, for example, one trying to follow the player from behind instead, or a random value that makes them target at other distances. You could also add a range for them to follow you and to stop following, if it's from any help.
Last edited by SuperInky (June 29, 2020 00:22:26)
- Discussion Forums
- » Help with Scripts
-
» Need Experienced: How to make enemy AI?