Looking for Help Improving a Slither.io Protocol 14 C++ Server #198760
Replies: 4 comments 2 replies
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
Happy to help — these are classic real-time multiplayer server problems. Let me address each category systematically. 1. Movement & Rotation SmoothnessThe shake/vibrate and jitter issues almost always come from one of two things: inconsistent tick rate or floating point accumulation error. Fix tick rate first — use a fixed timestep loop: #include <chrono>
const double TICK_RATE = 1.0 / 25.0; // Slither uses ~25 ticks/sec
void GameLoop() {
using clock = std::chrono::steady_clock;
auto lastTime = clock::now();
double accumulator = 0.0;
while (running) {
auto now = clock::now();
double deltaTime = std::chrono::duration<double>(now - lastTime).count();
lastTime = now;
accumulator += deltaTime;
while (accumulator >= TICK_RATE) {
update(TICK_RATE); // fixed step update
accumulator -= TICK_RATE;
}
// render/broadcast interpolated state
broadcast(accumulator / TICK_RATE); // alpha for interpolation
}
}Never pass raw 2. Snake Rotation — Angular Velocity CapSlither doesn't allow instant direction changes. It caps angular velocity. The official protocol uses approximately 0.2 radians per tick as the max turn rate. const float MAX_TURN_RATE = 0.2f; // radians per tick
void updateSnakeDirection(Snake& snake, float targetAngle) {
float diff = targetAngle - snake.angle;
// Normalize to [-PI, PI]
while (diff > M_PI) diff -= 2.0f * M_PI;
while (diff < -M_PI) diff += 2.0f * M_PI;
// Clamp to max turn rate
diff = std::clamp(diff, -MAX_TURN_RATE, MAX_TURN_RATE);
snake.angle += diff;
}Tweak 3. Body Segment FollowingSegments should follow the path the head traced, not follow the segment in front of them directly. Direct following causes accordion/bunching artifacts. Use a path buffer approach: struct PathPoint {
float x, y;
double timestamp;
};
struct Snake {
std::deque<PathPoint> pathHistory;
std::vector<Segment> segments;
float segmentSpacing; // distance between segments
};
void updateSegments(Snake& snake) {
float totalDist = 0.0f;
for (int i = 0; i < snake.segments.size(); i++) {
float targetDist = (i + 1) * snake.segmentSpacing;
// Walk back through path history to find correct position
for (int j = 0; j < snake.pathHistory.size() - 1; j++) {
auto& p1 = snake.pathHistory[j];
auto& p2 = snake.pathHistory[j + 1];
float segLen = dist(p1, p2);
if (totalDist + segLen >= targetDist) {
float t = (targetDist - totalDist) / segLen;
snake.segments[i].x = lerp(p1.x, p2.x, t);
snake.segments[i].y = lerp(p1.y, p2.y, t);
break;
}
totalDist += segLen;
}
}
}Record a path point every tick. Segments then sample the correct position along that path based on their index × spacing distance. 4. Boost BehaviorDuring boost, Slither does two things simultaneously:
const float BASE_SPEED = 5.5f;
const float BOOST_MULTIPLIER = 2.0f;
const float MASS_BURN_RATE = 0.5f; // mass units per tick while boosting
void updateSnake(Snake& snake, bool isBoosting) {
float speed = BASE_SPEED;
if (isBoosting && snake.mass > MIN_MASS_TO_BOOST) {
speed *= BOOST_MULTIPLIER;
snake.mass -= MASS_BURN_RATE;
updateSnakeLength(snake); // recalculate segment count from mass
spawnFood(snake.x, snake.y, MASS_BURN_RATE); // ejected mass becomes food
}
snake.x += cos(snake.angle) * speed;
snake.y += sin(snake.angle) * speed;
snake.pathHistory.push_front({snake.x, snake.y});
}The food spawning during boost is important — it's what creates the food trail that other snakes chase. 5. Client-Side Interpolation (reduce jitter on clients)Even with a perfect server, clients will see jitter if you're sending raw positions. Send positions every tick but have clients interpolate between the last two received states: // Server: send state snapshot every tick
struct SnakeState {
uint32_t snakeId;
float x, y, angle;
uint32_t timestamp; // server tick number
};
// Client renders at: currentServerTime - 100ms (interpolation buffer)
// Interpolates between snapshot[n] and snapshot[n+1]100ms interpolation buffer is standard for games of this type. It trades a tiny bit of latency for smooth visuals. 6. Protocol 14 Packet TimingFrom looking at your repo briefly — make sure position update packets are sent every tick for nearby snakes and throttled for distant ones. Slither uses a sector/zone system where snakes far from the viewport get lower update frequency. Sending full-world updates every tick to every client is the most common cause of network sync issues on private servers. Suggested debugging order
Happy to look at specific sections of your code if you share the relevant movement/tick files from the repo. What does your current game loop look like? |
Beta Was this translation helpful? Give feedback.
-
|
Perfect, thank you very much for taking the time to help me. I really appreciate it. The main server-related files in the project are:
Repository: Here are the answers to your questions: 1) Yes. I'm hosting the server on an Azure VPS. The goal is to create a private server where friends can play together and also organize matches against players from other teams. 2) This same project already exists in other countries, and those servers are fully functional. As far as I know, they usually handle around 20 to 30 concurrent players without any issues. 3) A friend of mine has already fixed several important issues, especially those related to snake rotation and movement. However, there are still many bugs that we're trying to solve so the gameplay matches the original Slither.io server as closely as possible. Some of the remaining issues are:
Our goal is to replicate the original server behavior as accurately as possible. The only intentional difference is that we reduced the map size and added a Battle Royale-style dome for matches between friends and rival teams. One detail that might be important: a friend of mine already used Wireshark to analyze the traffic from one of the private US servers. Thanks to that, we were able to replicate a large part of the server's behavior and fix several issues. The problem is that we've reached a point where packet analysis alone isn't enough. The most important mechanics seem to be implemented entirely in the server itself, such as the exact collision logic, body synchronization, smooth turning, boost behavior, and other internal algorithms that simply can't be reconstructed by looking at network traffic alone. That's where we're currently stuck. 4) I have a friend who is a programmer, and he has already fixed many bugs in both the mods and the server. However, these more complex mechanics are still very difficult to reproduce. We know that some private US servers have managed to make their gameplay almost identical to the official Slither.io servers, but unfortunately they don't like sharing how they achieved it. If you have any suggestions about where we should start investigating these mechanics, or if you know of any techniques that could help us reproduce the original server behavior more accurately, I would really appreciate your advice. Any guidance would be a huge help. |
Beta Was this translation helpful? Give feedback.
-
|
Here’s the thing: I’m in China, and I need a VPN to use this app. But if I want to subscribe, I can’t—I don’t have a credit card; I only have a debit card, and the only payment options are Alipay or WeChat Pay, so I can’t subscribe. Now it says that accounts without a subscription are limited to 20 messages per day. What should I do? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Discussion Type
Product Feedback
Discussion Content
Hello everyone,
I'm currently working on a Slither.io private server written in C++, hosted on a VPS. The server is based on Protocol 14 and was originally developed by a friend of mine, but unfortunately he abandoned the project before it reached a stable state.
The server is functional and players can connect, move, eat food, grow, and interact with each other. However, there are still several issues that prevent it from behaving like the official Slither.io servers.
Current Problems
Some of the issues we've identified so far include:
Snake rotation does not feel smooth or accurate.
Turning speed differs from official servers.
Movement speed feels inconsistent compared to official gameplay.
Snakes sometimes appear to "shake" or "vibrate" while moving.
Position updates can look jittery under certain conditions.
Tick rate / update timing may not match the original game.
Body segments do not always follow the head smoothly.
Boosting behavior does not perfectly match official servers.
Collision detection may occasionally feel inaccurate.
Spawn behavior still needs improvement.
Network synchronization between client and server needs refinement.
Some protocol packets may not be implemented exactly as the original game.
Interpolation and prediction behavior are likely different from the official implementation.
What I'm Looking For
I'm trying to make the server behave as closely as possible to the official Slither.io experience.
If you have experience with:
Slither.io protocol reverse engineering
Game networking
Real-time multiplayer servers
C++
Entity interpolation and movement systems
Tick-based game loops
your help would be greatly appreciated.
Testing
You can compare behavior by:
Connecting to an official Slither.io server.
Using NTL Mod or another client modification for comparison.
Connecting to my private server running on VPS/Linux.
Comparing movement, rotation, speed, boosting, collisions, and overall gameplay feel.
Repository & Resources
I will provide:
The server repository.
Protocol 14 documentation.
A JavaScript implementation of the Protocol 14 client.
Access information for testing.
Unfortunately, some people who already have working private Slither.io servers have chosen not to share information or help newer developers. Because of that, I'm hoping to collaborate with the community and learn from others who are interested in the project.
Any contribution, suggestion, code review, testing, or technical advice would be greatly appreciated.
Thank you very much for your time and support! 🙂
protocol14.js
Here is the server that my friend created: https://github.com/bots2020/servidor_slither
Beta Was this translation helpful? Give feedback.
All reactions