Skip to content

Repository files navigation

SlitherAI

SlitherAI

Experimental JavaScript AI tools for slither.com

JavaScript Dependencies License

Paste a script into the browser console to experiment with autonomous play, assisted manual play, or observation-only game telemetry.

⚠️ Educational and research disclaimer

This repository is published for education, defensive research, and experimentation with browser-based game AI. It is not an official slither.com product, is not affiliated with or endorsed by slither.com or its owners, and does not provide permission to access or modify their services.

The included autopilot and assisted-control scripts may be prohibited by the slither.com Terms of Service, including provisions concerning reverse engineering, automation, bots, scripts, and modifying or interacting with the game service. Do not use them on slither.com or any live service unless you have explicit permission from the service owner. A disclaimer does not override third-party terms, grant authorization, or guarantee that use is lawful.

You are solely responsible for how you use the code, for complying with applicable law and third-party terms, and for any consequences including account suspension, termination, data loss, or other claims. The authors and contributors provide this repository for educational purposes only, without guarantees, and accept no responsibility for unauthorized use.

Never paste unknown code into a browser console on a page containing sensitive information. Read the complete Security, legal, and responsible-use notice before continuing.

Choose a script

Script What it does Browser global
autopilot-ai.js Full autopilot. Reads visible game state, plans movement, and controls steering and boost. SlitherAI
assisted-ai.js Assisted manual mode. You drive; the AI intervenes only when a collision is imminent and you cannot reasonably react. It can be installed directly in Tampermonkey. SlitherAI
manual-recorder.js Observation-only recorder. Tracks a manual session and prints a strategy report. It does not control the game. SlitherAIRecorder

All three scripts are standalone, dependency-free browser scripts. There is no npm install, build step, or server component.

Quick start

  1. Open slither.com in a desktop browser.
  2. Start a game, then open Developer Tools (F12 or Cmd+Option+I on macOS).
  3. Open the Console tab.
  4. Copy the complete contents of the script you want to try and paste it into the console.
  5. Press Enter and watch the on-screen HUD or console output.

For the full bot, paste autopilot-ai.js. It exposes:

SlitherAI running with the live HUD

SlitherAI running with its live in-game HUD.

SlitherAI.status();          // Show current mode and metrics
SlitherAI.toggle();          // Switch between autopilot and manual control
SlitherAI.setEnabled(false); // Take manual control
SlitherAI.setEnabled(true);  // Resume autopilot
SlitherAI.stop();            // Stop the bot
SlitherAI.resetStats();      // Reset in-memory session statistics

The HUD also includes a control button, so you can hand control back without using the console.

Assisted mode

Use assisted-ai.js when you want to play manually with a narrow safety net. The AI stays hands-off during normal play and takes control only when its time-to-contact model determines that a death is imminent.

Install with Tampermonkey

  1. Install the Tampermonkey extension for your browser.
  2. Open the Tampermonkey dashboard and choose Create a new script.
  3. Delete the starter template.
  4. Copy the complete contents of assisted-ai.js and paste it into the editor.
  5. Press Ctrl/Cmd+S, or use File → Save. Make sure the script is enabled.
  6. Open or reload https://slither.com/. The SlitherAI HUD should appear after the game loads.

Tampermonkey runs this file automatically only on the four slither.com URL patterns in its header. To stop the safety controller for the current tab, use the HUD button or run SlitherAI.stop() in the page console. To disarm it while leaving the HUD visible, use SlitherAI.setEnabled(false).

SlitherAI.status();
SlitherAI.sensitivity('low');    // 'low' | 'normal' | 'high'
SlitherAI.setEnabled(false);     // Disarm the safety net
SlitherAI.toggle();
SlitherAI.stop();

While idle, SlitherAI does not write movement or boost controls. When it intervenes, it restores your latest mouse direction and boost intent when handing control back.

Manual recording

Paste manual-recorder.js before or during a manual session to collect observations without changing how you play:

SlitherAIRecorder.status();
SlitherAIRecorder.report();
SlitherAIRecorder.stop();
SlitherAIRecorder.reset();

The generated report is an interpretation of visible client state, not an authoritative game replay or score record.

How the autopilot works

autopilot-ai.js rebuilds a bounded snapshot of the visible board on each planning tick. It estimates nearby snake motion, checks collision and arena-edge risk, simulates candidate headings, and chooses among these modes:

Mode Purpose
EVADE Escape immediate collisions, edge traps, and closing encirclements.
CUT Intercept a predicted enemy path.
TRAP Orbit and pressure a smaller snake.
FEAST Reach valuable food left by a recent death.
FARM Sweep a dense food area.
ROAM Travel safely when there is no higher-priority opportunity.

The planner only knows what the game client exposes. It has no off-screen radar, and predictions can be invalidated by lag, server correction, or a sudden opponent turn.

Testing and development

There is no build pipeline. Run syntax checks after editing:

node --check autopilot-ai.js
node --check assisted-ai.js
node --check manual-recorder.js

The assisted-mode behavior tests are in assistedai-test.js:

node assistedai-test.js
node assistedai-test.js --verbose

The live-test runners are experimental and require a locally installed Chrome or Chromium browser. They launch a real browser and connect to the public game, so results are network-, server-, and opponent-dependent:

node live-test.js --seconds 120
node live-test.js --seconds 120 --runs 3 --json > results.json
node live-test.js --bot assisted --seconds 120

--bot autopilot is the default. Use --bot assisted to inject assisted-ai.js; the live runner then labels assisted interventions as SAVE and still reports them under evasion telemetry.

Do not treat estimated kills, survival time, or a single run as a benchmark. The game client does not expose every event authoritatively.

Project layout

File Purpose
autopilot-ai.js Full autonomous bot.
assisted-ai.js Manual play with imminent-death intervention.
assistedai-test.js Offline assisted-mode behavior tests.
manual-recorder.js Observation-only manual session recorder.
live-test.js Experimental live browser test runner.
live-test-osx.js macOS-specific live test runner.
brand/ Repository branding assets.
styles/ Design and style notes.

Contributing

Issues, bug reports, and pull requests are welcome. Please include:

  • Which script and browser you used.
  • The relevant console error or HUD state.
  • Whether the problem is reproducible.
  • Any syntax-check or test output.

Keep the browser scripts dependency-free and guard access to slither.com globals, since the page state is unavailable during loading, connection, and respawn transitions.

Security, legal, and responsible use

The local slither_tos.txt file is included as a prominent warning and reference, not as permission to use the scripts. Review the current terms from the service owner before interacting with any live service; the local copy may be incomplete, outdated, or unofficial.

This project can read page state and write game-control values when injected into a browser tab. Do not run it on accounts, websites, or environments you do not own or have explicit authorization to test. Do not use it to bypass anti-cheat, authentication, rate limits, access controls, or network protections. Do not redistribute proprietary game-client code or assets.

This notice is not legal advice and cannot protect a user from contractual, civil, criminal, platform, or account consequences. If you need a legally safe deployment or research plan, obtain permission from the relevant service owner and consult a qualified lawyer in the applicable jurisdiction.

License and attribution

This project is released under the Apache License 2.0.

The captured slither.com page assets are retained only as reference material. They are not part of the launcher and should not be redistributed or modified as if they were project-owned code. slither.com and its game client remain the property of their respective owners.

About

Experimental vanilla JavaScript AI scripts for slither.io: autopilot and assisted manual play.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages