Slither.io-bot: If zoomed very far out, the view slowly zooms in.

Created on 8 May 2016  Â·  24Comments  Â·  Source: ErmiyaEskandary/Slither.io-bot

Has anyone else noticed this?

Most helpful comment

@ChadSki You think this would work better?

// Modify the redraw()-function to remove the zoom altering code.
var original_redraw = window.redraw.toString();
var new_redraw = original_redraw.replace('gsc!=f&&(gsc<f?(gsc+=2E-4,gsc>=f&&(gsc=f)):(gsc-=2E-4,gsc<=f&&(gsc=f)))', '');
window.redraw = new Function(new_redraw.substring(new_redraw.indexOf('{')+1,new_redraw.lastIndexOf('}')));

You can try it out here: https://github.com/tjorim/Slither.io-bot/tree/zoomfix -> https://github.com/tjorim/Slither.io-bot/raw/zoomfix/bot.user.js

All 24 comments

I have the same problem from the beginning.
I think that is normal.

We could have a "desired zoom level" variable that the scroll wheel updates. Then, in our main loop, keep reassigning the desired zoom level, instead of letting it shrink.

This would just be a waste of CPU cycles. You won't stay zoomed out anyway for too long. Even if you do, it zooms in very slowly and then you can just reset it back. It doesn't make a major difference and would just be some next random code which is just a waste of CPU cycles.

I do stay zoomed out for very long -- it's much more strategic, especially when you have a large snake.

Manually resetting the zoom is annoying, and it takes precision to scroll back exactly to the setting you were at before.

I may attempt this change and see how much it actually affects performance. Variable assignments usually aren't so expensive.

@ErmiyaEskandary Agreed, it does not bother me very much since it's happening very slowly. I would just ignore this little hiccup, it's not like a problem/bug in our own code I think.

@ChadSki

Variable assignments usually aren't so expensive.

Yeah but not if you are checking every I don't know seconds.

No checks, just forcibly assigning over and over. But we'll have to see what the real-life performance is like.

Giving it is own interval (of 100) has a big hit on FPS at first sight.
It also drives me nuts to see the zoom jumping constantly.

Putting this into the bot.startBot() reduces the lag to a minimum,
one disadvantage is it only updates every second (which seems better than each 100 ms).

Will soon create a new branch in my repo for this.

@ChadSki Can you please try the steady zooming out here?

It doesn't make a major difference and would just be some next random code which is just a waste of CPU cycles.

@tjorim I will try this later tonight. Thanks for taking a stab at it!

@tjorim I tried it out... It seems awkward to have the screen constantly jittering back to it's original zoom point...

Unless there's a way to increase the update interval without causing slowdowns, I'm sticking to the zooming in bug.

I agree about the jitter. Hmm, perhaps it would be better to locate what's changing window.gsc and neutralize it there? There are other things about the game's rendering behavior that I'd like to change...

Maybe infeasible for now until we have a proven way of monkeypatching Slither.io's code.

Yeah, already searched the code but nothing really caught my eye right away.
On May 12, 2016 7:07 AM, "Chad Z" [email protected] wrote:

I agree about the jitter. Hmm, perhaps it would be better to locate what's
changing window.gsc and neutralize it there? There are other things about
the game's rendering behavior that I'd like to change...

Maybe infeasible for now until we have a proven way of monkeypatching
Slither.io's code.

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/ErmiyaEskandary/Slither.io-bot/issues/97#issuecomment-218661381

Could someone try the following script out?
https://github.com/tjorim/Slither.io-bot/raw/zoomfix/bot.user.js

@tjorim custom redraw function? What did you change?

@ChadSki, I only removed the following three lines of code:

gsc != f && (gsc < f ? (gsc += 2E-4,
gsc >= f && (gsc = f)) : (gsc -= 2E-4,
gsc <= f && (gsc = f)))

Here is the original beginning of the redraw()-function:

var dfs = s, maxp = 0, fps = 0, redraw = function() {
    fps++;
    var c = mc.getContext("2d");
    if (animating) {
        if (snake) {
            var f = .5 + .4 / Math.max(1, (snake.sct + 16) / 36);
            gsc != f && (gsc < f ? (gsc += 2E-4,
            gsc >= f && (gsc = f)) : (gsc -= 2E-4,
            gsc <= f && (gsc = f)))
        }
        var f = view_xx
          , b = view_yy;

I think that even the whole if(snake) {} could be removed.

@tjorim That causes an issue for longevity. If we include that in our code, then the bot may break unexpectedly with updates from slither's side.

@ChadSki You think this would work better?

// Modify the redraw()-function to remove the zoom altering code.
var original_redraw = window.redraw.toString();
var new_redraw = original_redraw.replace('gsc!=f&&(gsc<f?(gsc+=2E-4,gsc>=f&&(gsc=f)):(gsc-=2E-4,gsc<=f&&(gsc=f)))', '');
window.redraw = new Function(new_redraw.substring(new_redraw.indexOf('{')+1,new_redraw.lastIndexOf('}')));

You can try it out here: https://github.com/tjorim/Slither.io-bot/tree/zoomfix -> https://github.com/tjorim/Slither.io-bot/raw/zoomfix/bot.user.js

Perfect!!!

@ChadSki So it works ?

@tjorim If it does and it is optimised, make a PR !

It works perfectly! I've been pasting those three lines directly into the console, which works but I need to redo it every time the page refreshes.

Please make a PR and let's get this integrated!

:+1: if there is no performance drop. For the time being, NO PRS will be
merged due to a whole new big change coming up @ChadSki ;) gitter .... But
will definitely be reviewed...

Latest version - fixed...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Drflash55 picture Drflash55  Â·  5Comments

phatass69 picture phatass69  Â·  5Comments

Drflash55 picture Drflash55  Â·  4Comments

Tomboman picture Tomboman  Â·  5Comments

TheFlyingPlatypus picture TheFlyingPlatypus  Â·  6Comments