Skip to content

About

Headless Slither.io simulator in Rust for custom servers and bot development.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

SlitherSim

A headless Slither.io simulator in Rust for custom servers and bot development.

Quick start | Portable bots | WebSocket server | Contributing

CI Release crates.io Rust 1.99+ License: MIT

Stylized snake animation with the cargo run --locked -- serve command

Quick start

Install Rust 1.99 or newer and its platform build tools, then run a food-seeking bot:

git clone https://github.com/NikitaMGrimm/slither-sim.git
cd slither-sim
cargo build --release --locked
cargo run --release --locked --example portable_bot -- --steps 200

The bot runs locally, prints a summary and exits. No game window opens.

For a simple portable controller in Python:

python examples/portable_bot.py --steps 200

It needs Python 3.11+ and the build above, and uses only the standard library. On Windows, use py -3 if python is missing.

More examples: embedding the simulator and the Forager on core observations. To use the library elsewhere, run cargo add slither-sim; for the CLI alone, cargo install slither-sim --locked.

Rust bots can reuse the tuned Forager policy through client::ForagerBot::new() or default(). A4 (A4-mean) is the only optimized policy. Offline builds get bot::Forager::default() with --no-default-features --features bot.

Download a release

Release archives hold the slither-sim CLI and the C ABI library and header, so Rust is not needed. Builds cover Linux x86-64 and ARM64 (glibc 2.17+), macOS (Apple silicon and Intel) and Windows x86-64. Check downloads against SHA256SUMS.

curl -LO https://github.com/NikitaMGrimm/slither-sim/releases/latest/download/slither-sim-x86_64-unknown-linux-gnu.tar.gz
tar -xzf slither-sim-x86_64-unknown-linux-gnu.tar.gz
echo '{"op":"reset","agents":1}' | slither-sim-x86_64-unknown-linux-gnu/slither-sim serve

The macOS and Windows builds are unsigned. On macOS, a browser download is quarantined; clear it with xattr -dr com.apple.quarantine on the extracted folder. On Windows, unblock the .zip before extracting (Properties → Unblock, or Unblock-File in PowerShell), or choose More info → Run anyway if SmartScreen stops the CLI.

Try the WebSocket server

Start a shared world in one terminal:

cargo run --release --locked -- host

From the same checkout in another terminal, connect the bot:

cargo run --release --locked --example portable_bot -- --url ws://127.0.0.1:8766/slither --steps 200

The host binds loopback by default. Stop it with Ctrl+C. Server configuration covers custom worlds and remote hosting. Linux hosting sets up a public server as a service. In our test, one core of an AWS c7a.medium ran 500 fully grown bot players over plain WebSockets for 30 minutes without falling behind (details). All settings lists defaults, limits and timing behavior.

Choose an interface

Goal Interface
Run a bot in simulation or on protocol-19 servers client JSON API, or Rust BotRunner.
Connect WebSocket clients to a shared world host.
Control all slots with direct simulation observations serve JSON API, or Rust Simulator.
Run serve sessions in-process from Python Python package.
Run serve sessions in-process from any language C ABI, or Rust transport::Session.

client bots decode the same packets in simulation as on a real server. serve observations come straight from the world, with no network delay. See interface versions for compatibility.

Defaults and fidelity

The default world, Config::official(1), starts sized for its players, then grows at once when players join and shrinks gradually when they leave. This is our design; it does not reproduce official radius waves. It combines measured movement and protocol constants with provisional visibility, spawning and ecology models; it is not an exact official replica. Config::sandbox() uses the same mechanics in a compact fixed arena.

Config::battledome() is our own mode, not an official one: a one-way pit, a permanent 400-point size floor with free boosting at it, and a rolling kill score. See rules and evidence limits for measured behavior and gaps.

Development

Report bugs in Issues with the command, configuration and expected behavior.

MIT. Independent of Slither.io.

About

Headless Slither.io simulator in Rust for custom servers and bot development.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages