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

The Circle Method #318

Closed khumarahn closed 8 years ago

khumarahn commented 8 years ago

Hi!

I found this project extremely useful. I wanted to write a simple bot, but as I don't know any javascript or slither.io architecture, it wasn't accessible to me until I found this repo. I am very grateful to all the developers.

I modified the bot a bit. I removed all the clever stuff and made it go round a circle following its tail. It has been quite successful so far, the max score it reached was over 1.8 mln.

Here is a fresh screenshot: http://imgur.com/6uemNd3 Two leading snakes are driven by my algorithm. At the moment of writing this, both are still alive, and the largest one is 1.4 mln.

Here is a video https://www.youtube.com/watch?v=dv91cZjVzow of the old version of the bot being killed by an angry online streamer at a size of 1.1 mln. I improved the algorithm significantly since then.

I have been testing the Circle Method for quite some time now, and I have seen an increase of human players doing the same thing. But sooner or later they have to go to a toilet, and their snakes die. In contrast, the bot's poop is collected by the javascript garbage collector, and it can run longer.

For my algorithm to work, the snake has to be manually controlled until it has a size of several thousand. Then I form a counter-clockwise circle with it and then the bot can run.

I would suggest using the current bot that you developed until the snake reaches a size of 10 thousand say, and then starting the circle and switching to the circle algorithm. This has a potential of scoring very high fully automatically :-)

https://github.com/khumarahn/Slither.io-bot updated version: https://github.com/j-c-m/Slither.io-bot/tree/_followself (branch) https://github.com/j-c-m/Slither.io-bot/blob/_followself/bot.user.js

khumarahn commented 8 years ago

image still running 2.5 mln is a personal record

ChadSki commented 8 years ago

Slow and steady wins the race, eh?

HamishBlank commented 8 years ago

This tactic is hilarious to watch 10/10

clemens-tolboom commented 8 years ago

I'm not able to test this ... this version has lots of stutter on my Chrome on Mac. Switching to mobile rendering makes it a little better. I once draw the circling in action but not sure when that triggers.

I like the idea and will try to build it into my task branch soon

khumarahn commented 8 years ago

The small bot died at around 1.1 mln because of some browser or javascript problem: there was Aw snap screen in chromium.

The big bot lived to 4.1 mln. Then, it seems, the server was brought down bigbot

There are many problems running the bot. It often crashes, especially on weaker computers. Probably some memory management issues.

clemens-tolboom commented 8 years ago

256 * 256 * 256 * 256 === 4294967296 (uint32: unsigned 4 bytes int) so your score is near that number :p

On iPad is did the circle manually (when bigger then 8000 form circle) and managed to get 75000 then the growth stalled. It was fun to do. Some big snakes tried to surround me but failed and provide food :)

clemens-tolboom commented 8 years ago

I tried a naive implementation of follow tail. So I studied @khumarahn code which assumes the user guides the snake

To make that into a task we need

See https://github.com/ErmiyaEskandary/Slither.io-bot/tree/feature/task-execution and 557ba5323e9bc51c28cd42fe758f6782b13165e7 for my naive implementation. You need to enable the FollowTail task.

clemens-tolboom commented 8 years ago

I forgot to tell the task is a sequence of (sub)tasks which I do not have in #275. Guess I could use MoveToXY but how to create circle without dying?

One has to disable AvoidCollisionEnemySnake on the way too.

@seple please help with create circle :p

When as circle I rediscovered the keyboard ... just press left key (counter clockwise) or right key (clockwise).

Seple commented 8 years ago

hmmm (think)

Similarly #78 maybe 2in1 option?

Please check the CODE CIRCLE before version 0.9 option "Defense mode"

phrokton commented 8 years ago

I was eager to try this last night but I was unable to play merely to 8000 because I was so tired already when I read your post khumarahn.

On first run bot reached 165k. Wow. That's better than my prior personal best ~150k. It would have continue but wretched TimeWarner internet glitched.
I hope your changes are integrated as an option into the task execution branch so it will play itself to [a user editable] minimum, and drive itself to a user editable set of coordinates -- most preferably those already user edited for MoveToXY as I actively dislike dead center use.

Guess I could use MoveToXY but how to create circle without dying?

Grow to functional minimum, start overlapping small circle, allow bot to expand to head-to-tail? @clemens-tolboom

find hard to [create circle] in the center

I used a not-center location. At 40k the perifery was near the center.

Why counter-clockwise?

When will this branch..

https://github.com/khumarahn/Slither.io-bot.C/blob/_followself/bot.user.js

..deviate from coiling? (that's what I call circling because it is aptly more aggressive)

vikasTmz commented 8 years ago

Over 2mil ? that's amazing. I reached about 0.3 mill in a similar implementation and the funny part is new unfortunate players get spawned inside my coil. There was one instance where about 10 snakes where spawned inside.

clemens-tolboom commented 8 years ago

I just fiddles a little more for #275 and has a feeble circle.

I have to read the other comments / hints :-p

clemens-tolboom commented 8 years ago

This is my video https://www.youtube.com/watch?v=Te9b9YjDQ-0 (still processing)

khumarahn commented 8 years ago

Very impressive video! By the way, it does not have to be a circle. A long and narrow oval would work also, provided max curvature is not too high. It may be easier to accomplish. On the other hand, the circle is more fun.

When will this branch.. https://github.com/khumarahn/Slither.io-bot.C/blob/_followself/bot.user.js ..deviate from coiling? (that's what I call circling because it is aptly more aggressive)

Right now that branch is better ignored. There was some nice work by @j-c-m: he incorporated the Circle Method in his version of the bot. He also made some changes to improve the cpu consumption of his bot. I absolutely love how fast it is!

Then I also did some small but essential improvements to the algorithm. In my opinion, currently the best version of the circling algorithm is here: https://github.com/j-c-m/Slither.io-bot/blob/_followself/bot.user.js

Seple commented 8 years ago

Method Circle is prospective developmentally:

Good direction of development :+1:

khumarahn commented 8 years ago

ooops it went on air https://youtu.be/2dpFIEPg4Hw P.S.: avada kedavra is still alive at 4.26 mln, it works under the newest algorithm; two others were older. They have been encircled and died. It is quite hard to expand this close to the center. I should have changed their target area away from center, probably.

phrokton commented 8 years ago

What are the system specifications of those able to break 1 million? My browser invariably freezes when left unattended peaking at ~250k. :( This happens with chromium on OSX (32 gigs ram, i7) and Windows 10 (16 gigs ram, i5). Disabling all extensions other than TamperMonkey [most notably uBlock Origin] seems unproductive. I would like to provide logs.

It has never frozen in my presence. I usually want to fiddle with the bot: disable, grab food or harass those attempting to coil my snake, enable bot. I had thought too many on screen snakes so I moved farther from center.

I am [experimentally] uncertain of the impact of radius multiplier in the coil branch.

khumarahn commented 8 years ago

Hi, I had good performance with core 2 duo laptop with 4 gb ram, chromium, linux. One of big snakes in youtube video above was running on that computer, and it was not even spinning the cooling fan half of the time.

I'd recommend to remove unnecessary addons, and make sure that gpu acceleration for canvas is enabled (google it).

clemens-tolboom commented 8 years ago

@phrokton what code do you use? @j-c-m or @khumarahn ?

khumarahn commented 8 years ago

Closing this. Refer to https://github.com/j-c-m/Slither.io-bot if you are interested.

cooleos commented 7 years ago

How do you even get a Circle Bot for Slither.io?

crazyyi commented 6 years ago

@khumarahn You inspired me to write a clever AI for my own version of Slither.io ! Thank you!

cooleos commented 6 years ago

how tf do you know my name?

On Mon, Oct 23, 2017 at 12:14 AM, Aaron notifications@github.com wrote:

@khumarahn https://github.com/khumarahn You inspired me to write a clever AI for my own version of Slither.io ! Thank you!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ErmiyaEskandary/Slither.io-bot/issues/318#issuecomment-338543434, or mute the thread https://github.com/notifications/unsubscribe-auth/AWZkKb8IG_uUmsgSBkahIgIiFXwWJIJmks5svBKHgaJpZM4JFQza .

ChadSki commented 6 years ago

We didn't know your name, but GitHub did when it sent you an email notification.

Now that you've replied via email, we can see the header: On Mon, Oct 23, 2017 at 12:14 AM etc

cooleos commented 6 years ago

oh, lol my mad, sorry for being rude xD

On Wed, Nov 1, 2017 at 4:14 PM, Chad Z notifications@github.com wrote:

We didn't know your name, but GitHub did when it sent you an email notification.

Now that you've replied via email, we can see the header: On Mon, Oct 23, 2017 at 12:14 AM etc

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ErmiyaEskandary/Slither.io-bot/issues/318#issuecomment-341227737, or mute the thread https://github.com/notifications/unsubscribe-auth/AWZkKRl0W2lDo0INVMti4UhfinMkgk_qks5syNEVgaJpZM4JFQza .

cooleos commented 6 years ago

did you guys create a perfect circle bot yet

On Wed, Nov 1, 2017 at 4:50 PM, ⠀⠀ cooleostar@gmail.com wrote:

oh, lol my mad, sorry for being rude xD

On Wed, Nov 1, 2017 at 4:14 PM, Chad Z notifications@github.com wrote:

We didn't know your name, but GitHub did when it sent you an email notification.

Now that you've replied via email, we can see the header: On Mon, Oct 23, 2017 at 12:14 AM etc

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ErmiyaEskandary/Slither.io-bot/issues/318#issuecomment-341227737, or mute the thread https://github.com/notifications/unsubscribe-auth/AWZkKRl0W2lDo0INVMti4UhfinMkgk_qks5syNEVgaJpZM4JFQza .