ermiyaeskandary / Slither.io-bot

Just for fun and AI. Written in Javascript, this is a project which the aim is to make a computer play against humans inside a human-driven game, which is in this case Slither.io. The goal is simple - try and make the snake live and get as long as possible.
Mozilla Public License 2.0
195 stars 124 forks source link

Avoid circling by other snakes #234

Open hnphi opened 8 years ago

hnphi commented 8 years ago

First , I want say the current script is fine and very good. But, i need some code detect when my snake be attacked ( surrounded by other snake ), some code let snake chasing its own tail. (not Defense Mode)

Sorry about my English. :)

ermiyaeskandary commented 8 years ago

We currently do not have circling avoidance in the master branch but there is in the A* OLD branch, if you want to look at anything...

ChadSki commented 8 years ago

Complex changes to the AI have been attempted... for now we are sticking with the simple circles-based approach.

However, feel free to attempt the feature! We're open to experimental/development branches with AI improvements.

kmatheussen commented 8 years ago

Are you sure it's that complex? How about checking if a snake covers at least 180 degrees, and if so, aim at that snake's tail?

Another thing is that since around 90% of the deaths are caused by another snake circling you, it seems strange that this issue should have low priority.

EDIT: I guess the number is closer to around 50% of the deaths.

ermiyaeskandary commented 8 years ago

@kmatheussen Recently changed labels - changing them now...

EDIT : Have a go at it and we'll be happy to merge it if approved !

77656233 commented 8 years ago

I have tried the old branche but it seems not to work. i only get a black screen. How can i add this to let snake go in round to not die when they try to circling me?

ermiyaeskandary commented 8 years ago

@ChristianGrieger ...

ermiyaeskandary commented 8 years ago

@ChristianGrieger Should be fixed now - install bot.meta.user.js and it be fine. CONFIRMED WORKING

77656233 commented 8 years ago

I will try thank you :) what is the differense to old and new bot? Is it less good? Can we get in contact in skype i have a question for another simular game a bot would ne cool for?

77656233 commented 8 years ago

Okay i tested it :) now i understand why its an old branche :/ So the new version is much better and i really hope this feature gets added soon to be enabled because snake dies really often if someone try to get qround it. But thanks for the update.

kmatheussen commented 8 years ago

If someone circles you, you are still most likely to die, even with the defence mode. If a snake cricles you close enough, the only thing it has to do to make you die is to go in another direction. The snake bodies are not set in a fixed position, they move a little bit depending on the angle it is pulled.

77656233 commented 8 years ago

But if you hold the circle a bit bigger and you run behind your own tail it can work or not ?

kmatheussen commented 8 years ago

I'm not sure. I think it may be simpler to avoid getting circled than to try running in a circle though. Not that it should be too difficult try to run in a circle either, but you have to decide how big the circle you want to create should be, and while doing that you have to make sure you don't bump into something while creating the circle. Detecting when getting circled, and getting away from it, doesn't seem so hard to implement, but I haven't tried.

77656233 commented 8 years ago

Okay so i have to wait for that get added :)

ermiyaeskandary commented 8 years ago

@ChristianGrieger Yep - hence why this issue is open and has the prio:important label ;)

ChadSki commented 8 years ago

But if you hold the circle a bit bigger and you run behind your own tail it can work or not ?

@ChristianGrieger No, the body of a snake does not stay exactly where you traveled (unless going in a straight line). Turning and curving pulls the body of the snake tighter. Even if you retrace your tail "perfectly", you will gradually draw a tighter circle.

Of course, if you draw things out and make the attacker circle you for a long time, they might slip up and die, or get distracted by other food.