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

Wiki error "How to override the game's javascript" #299

Closed pllsner closed 8 years ago

pllsner commented 8 years ago

I tested out this extension by hard-coding acceleration to always be enabled. Test was a success -- Left mouse clicks did not cause any speed change (always accelerated). Should read......... I tested out this extension by hard-coding acceleration to always be disabled. Test was a success -- Left mouse clicks did not cause any speed change (never accelerated).

ermiyaeskandary commented 8 years ago

Huh ?

pllsner commented 8 years ago

the value 2 disabled any acceleration of worm in my test. This wiki is reporting wrong results from the code change.

ermiyaeskandary commented 8 years ago

What page of the wiki ?

pllsner commented 8 years ago

[https://github.com/ErmiyaEskandary/Slither.io-bot/wiki/How-to-override-the-game's-javascript]

pllsner commented 8 years ago

reinstalled resource override. reran the test. a value of 2 disables any acceleration. Left mouse click does not accelerate.

ChadSki commented 8 years ago

@pllsner weren't you the one who got that working on the first place?

I copy+pasted that wiki page from your issue #274

ChadSki commented 8 years ago

Oh you mean the wiki is incorrect. Why don't you edit the wiki to be correct then? I thought I was clarifying things but probably got it wrong.

pllsner commented 8 years ago

274 states a value of 2 disables acceleration. Not a big deal, i just wanted to get the info correct.

i was not aware I could edit the wiki, or i would have. :)

ChadSki commented 8 years ago

So in your test, 2 was the same as 1? Or was 2 the same as 0?

2 is an odd number to use anyway, since it's not normally a valid value.

If you had set acceleration to 1, then it would always be enabled, right?

pllsner commented 8 years ago

2 was the same as 0. The logic in the function became false. original: function setAcceleration(b) { null != snake && (snake.wmd = 1 == b)} altered: function setAcceleration(b) { null != snake && (snake.wmd = 2 == b)} Given that b = 1 or 0, (the only values passed to this function) the table below explains the comparison operator == : original function: Operator..................Description...............Comparing............or.........Returns ....==.........................equal to.....................1 == b.............1 == 0.......false ..........................................................................................1 == 1........true altered function: Operator..................Description...............Comparing............or.........Returns ....==.........................equal to.....................2 == b.............2 == 0.......false ..........................................................................................2 == 1.......false by calling this altered function with setAcceleration(0), or setAcceleration(1), the condition is always false, so no acceleration ever occurs. .....update . modifying the function appears to disable any acceleration.

ChadSki commented 8 years ago

Oh, I see. :+1: Well feel free to edit this wiki and close the issue when fixed.

ChadSki commented 8 years ago

Oops wrong button lol.