Slither.io-bot: Add "escape strangle" attack mode for cutting off other snakes

Created on 9 May 2016  路  4Comments  路  Source: ErmiyaEskandary/Slither.io-bot

Hi guys,

I enjoy playing game automatically, so you must imagine how much i loved this project. Yesterday I tested the bot and came up with some sugestions.

Food gathering algorithm:

I experienced some fps drop after ~3000 length and were arround a large number of other snakes and corpses. I noticed that the current algorithm is iterating through some of the food checking for every other bit of food close by. I think it is better to iterate over possible clusters over the screen, check if there is a minimum quantity of food bits and then get the score of the food inside it. For example using circle with 100 of diameter and offseting it by x=50 or y=50 every loop. The cluster size could also be variable and roughly the size of the snake's head.

One other thing I have noticed is that the bot likes moving food more than snakes corpses. What do you guys think of identifying them and multiplying their distance for a factor, since we have to move more to get to them.

Escape strangle suggestion:

Another thing I have noticed is that it is easy to kill the bot by strangling it. What do you think about an mode that checks if a snake has made a circle of 250 dregrees(?) arround the bot and if that's the case run for the tail of that snake?

What do you guys think? I'm not a big fan of javascript but I'll help with what i can.

low

Most helpful comment

For example using circle with 100 of diameter and offseting it by x=50 or y=50 every loop. The cluster size could also be variable and roughly the size of the snake's head.

I agree. I tried making it based on the snake's width but due to issue #107 it was too small a circle.

One other thing I have noticed is that the bot likes moving food more than snakes corpses.

The bot definitely needs to be more aware of consuming an entire dead snake, instead of dilly-dallying around. The issue is it heads directly towards the most attractive cluster, instead of pathing through the dead snake.

Escape strangle

I would looooove to see the bot do this.

All 4 comments

For example using circle with 100 of diameter and offseting it by x=50 or y=50 every loop. The cluster size could also be variable and roughly the size of the snake's head.

I agree. I tried making it based on the snake's width but due to issue #107 it was too small a circle.

One other thing I have noticed is that the bot likes moving food more than snakes corpses.

The bot definitely needs to be more aware of consuming an entire dead snake, instead of dilly-dallying around. The issue is it heads directly towards the most attractive cluster, instead of pathing through the dead snake.

Escape strangle

I would looooove to see the bot do this.

@ChadSki I had the same issue using extensive search, tried increasing the radius but didn't get better performance even approximating the circles to squares.

About the escape strangle... I found this lightweight algorithm to check if a point is inside a semi-circle and if it is find the escape route, I implemented it in python:

def is_inside_semicircle(sh, st, snakeHead):
    '''
    sh = [x, y] coordinates of strangler's head
    st = [x, y] coordinates of strangler's tail
    snakeHead = [x, y] coordinates of bot's head
    '''
    radius = distance(sh, st)/2
    center = [(sh[0] + st[0])/2, (sh[1] + st[1])/2]
    dist = distance(center, snakeHead)
    if dist <= radius:
        det = (sh[0] - st[0]) * (snakeHead[1] - st[1]) - (snakeHead[0] - st[0]) * (sh[1] - st[1])
        if det > 0:
            return "Escape left"
        else:
            return "Escape right"
    else:
        return False

The problem is to figure out how it is going play along with the anti-collider and when to ignore the signal if a very big snake is taking a turn far from you.

Latest PR merge ?

Implemented at a basic level - will be improved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  10Comments

pllsner picture pllsner  路  9Comments

jellybabies picture jellybabies  路  7Comments

Drflash55 picture Drflash55  路  5Comments

tyschnoor picture tyschnoor  路  11Comments