Can someone help me with A.I.? I recently published a slither .io WIP, and I want to know how to code the A.I. of the other snakes. (I forget that they automatically turn it into a link whoops) I need replies not likes.
Could I have a link to the project?
Also could a leader make this a new topic?
This category is the closest to your question as I could find, let me know if you think it should go somewhere else
Well, maybe a following code? I’m not exactly sure how to make one though
I want it to react to being circled, and I want it to turn around when you get in front of it’s face. Other than that I just want it to act like a normal snake.
Do you want multiple snakes or only one and the player? How many is the most you’d want to have?
Is there a way to tell if they are being circled?
3 that’s what I’m going for anyway.
Ehh, I gotta think about that.
Let’s see what I can do
So 3 enemy snakes? In that case, it would make the most sense to have each of them be its own object, and just have them all have the same custom rule. Do you also want them to avoid each other?
Maybe you could try each snake setting some variables to its x position, y position, and rotation, then in the custom rule for all snakes (including the player) have it figure out if continuing in that direction from that position would make it collide with any of the object’s clones. Maybe also include a check for distance to the snake currently asking. Try to do this every frame, or if you want to make it easier every 3 frames, but each snake gets a frame to itself.
So it’d go
Frame 1. Snake #1 figures out if it’ll collide
Frame 2. Snake #2 figures out if it’ll collide
Frame 3. Snake #3
Frame 4. Snake #1
Ok! I’ll try that ASAP.
And I don’t know why.
It should work.
But it doesn’t.
Is being annoying.
The repeat forever with bring to front isn’t the best way to do that. Maybe consider using the set z index block if you can, or if it is out of beta before you finish this project.
Why does text 6 () repeat forever flip but in a check once if? Is this on purpose?
How is it being annoying? I don’t see anything anywhere that would make it turn if that’s what you want.
I was trying to make the eye look in the direction of the players finger. But then it just flipped infinitely and it looked sort of like it was facing Foreward.
The enemy doesn’t start with any length. And I’ve checked the code and I think it should work…
Yes, you have it doing basically repeat forever flip if last touch x is any number.
last touch x will always either be >= any number at all or < any number at all, and those are the conditions for the check if else you have for flipping. You’ll need to add a variable to save if the eyes are flipped and then flip based off of that and what you currently have.
Also, the enemy snake should start with some length instead of just being a head.
But I’ve double checked the code, and it should be happening, but it’s not…
You have it wait self length which for clones is 0. Use original object instead.
I had a similar problem in one of my projects and it took me hours to figure out.
how did i not see that *facepalm
It took me ten minutes and I only did it so quickly because you used an iPad variable for the player snake.
Be glad it wasn’t in there for literal months.