Welcome to MultiSnake
What is MultiSnake?
MultiSnake is the worlds first multiplayer snake. MultiSnake is not a knock-off like slither.io, or powerline.io, but it is truly, at it's core, a snake game. There is only ever one apple on the map, and players have to race to get to it. Of course, classic snake is not enough, so we added a couple twists:
- Different Game Mods including small map, fog, tag, redlight, and classic
- Blocks that spawn to block you
- Fun automatically generated usernames like "PinkDuck45" (but don't worry, you can still choose custom ones)
Because MultiSnake is a multiplayer game, there are a lot of strategies that one can use. Here are a couple good ones that will never fail you, and a couple advanced ones for the serious gamer. Here are some good general guidelines:
Twisting: we all know that sometimes it is impossible to get the apple. There will be times where 3 snakes will all run at it and they will all die. To take advantage of that, navigate to a clear spot on the map and coil you body around and around until their is an opening for you to jump in an take the apple. Then go back to twisting and wait some more.
Kamikaze: sometimes it's just so hopeless. You keep dying over and over. A snake is at 8 apples and about to win. Here is what you do. It is all about timing. Get one apple to boost with and get right in front of the other snakes path. Don't mind your own life. Your only goal here is to beat the other snake. Boost at just the right moment and he'll never know what hit him
Phasing: this technique needs a lot of practice to master. Spawn some apples by eating 5 or so apples. This trick is also about timing, and is mostly instinctive. Get to square right next to a block and smash boost button (space bar). If you timed it right, you'll "phase" through the block. In a real game, you can use this to escape other snakes trying to kill you, and blocks will no longer be a problem.
How to play different game modes
- Public- All the public rooms have the same rules as normal snake. You can not go backwards onto yourself. Blocks will spawn every 5 apples eaten, and you can not run into them, other snakes, the walls, or yourself
- Small- the same rules as the public rooms, but you no blocks spawn and the map is a lot smaller
- Fog- same rules as public, but blocks do not spawn, and fog does. You can not see other players in the fog.
- Redlight- original idea was by @rickyson, and he said to do something from squidgame. Luckily, the game redlight greenlight is in the public domain, so I can use it. Hold the spacebar to freeze your snake when the light becomes red. It will turn yellow first, though, so you have time to react. Get to ten apples to win. If you are not frozen when the light turns red, you die!
- Tag- Eat an apple to become "it" and turn yellow! Tag other people to kill them! Walls will not spawn. Get to ten apples to win!
Thanks to @Coder100 for helping with bugs back in beta. Thank you to @PYer for coming up with ideas for mods. Thank you to @ch1ck3n for helping with speed of the game. Thank you to @rickysong and @Redman for helping with testing. Lastly, thank you to the entire discord community for the support and helping to find bugs!
Why was MultiSnake made?
A message from the creator
I had already made a chatroom, and I thought "what if I put into practice what I learned from that project, and use it to make a multiplayer game?". So I did. After hours of reading tutorials later, I had a nice stream of data set up. My client could communicate with the server, the server could respond. I did not have to mess around to much initially with the front end, as I copied and pasted the game set up from that first snake game.
A thousand lines of code later, I had a horribly styled homepage, and a fully working multiplayer game framework. Player picked their usernames and the room that they wanted to join, and they were in. They could play around, and that was it.
There was one problem. The game was slow. I spent long hours trying to figure out how to fix it, and then it came upon me. In the code, I had a function that was called every 100ms. That's 10 times a second. Not very fast, but coupled with the fact that I was looping through an array of 10K per room in every function called, and this with the fact that I had 4 logic functions, I was looping through ~40K times every 100ms. That is a lot to be done in 100ms. And not only that, but I then had to send it over to the client, another 10 or so milliseconds gone. I was lagging hard. As @Wheysted put it,
I set to work. I consolidated all the loops into one and changed the game logic so the functions were called only 10K times a room. Still not good. I changed up the logic on when the snake dies. What I was doing was just changing the value of the snake to
"dead_snake". But this did not work well. Soon my code was polluted with
"dead_snake"s all over the place. Not good. I then totally turned the game upside down and changed it to deleting the snake when it dies. This was a lot harder than you might think, but I managed. There. Now it only loops ~5 times per room. A lot better.
A while later, I had the first mod, and the stylesheet was greatly improved. The mod was called "small", and I was very impressed at what I could do. So, I set to work. Because of the way I built it, it was super easy to just add a couple lines of code and change up the logic to create new mods. So I spit them out. I was pulling mods out of my pockets left and right, one every week. But then.
I went of repl.it trending
But that didn't stop me. I kept going. I spit out the redlight greenlight mod. And that's when I realized that every time I added a new mod, my game lost speed. I stopped. I thought. I thought some more.
Where we are now
I am currently rewriting all ~3K lines of multisnake code to make it more efficient, readable, and less time-consuming. Oh, and Im adding ads.
Chat now works! https://multisnake.sojs.dev now redirects to https://mulitsnake.xyz without problem. The two highly talked about mods have finally been released!
FOG OF WAR Fog is generated as the game goes. You cannot see other people in it. Have fun!
A tiny little map.
Note: No obstacles spawn on mods.
New Update also includes: new stylesheet (don't worry, you still type in your username) SOON TO COME:
Bots - I will be making a website where you can make your own and submit them. That way, there will always be people to play against. You will know that they are a bot because their username will be [BOT].bot name. (Made by .username.), where people who submit a bot choose the name.
MORE THAT CAME OUT IN THE UPDATE:
This can be used to make a variety of projects. It is currently used in the site to tell how many people are online Currently its only endpoint it https://multisnake.xyz/api/v1/rooms that gives you a nice list of rooms, their names, the people in them, the quantity of snakes in them, the type of room, the last time it was visited, and more!
- online counter from 1.2.0 now works.
Images of styling:
- Push to cloudflare (more secure and faster for you)
- New loading screen + tips
- New homepage with fancy bouncing arrow animation
not from codepen
- Tips and tricks if ya click that down arrow!
- [mod] A new mod! TAG mode! Eat apples to become "it" and tag other players to kill them!w Get to ten to win! Wow!!
- Put a boot onto the repl- even faster now!
Just released another mod, super excited for that!! This one was suggested by @rickysong, and it is a lot of fun! It is the same concept as classic snake, but you have to freeze when the light turns red otherwise you'll die! Don't worry though- the light will turn yellow first so you know to smash the spacebar down and hold it there until it goes back to green. It's a lot of fun, go try it out.
Also, the readablity of the code has been greatly increased, and I have explained in comments throughout what each line does, so you can go and understand it.
The next update will be huge. I am rewriting all of multisnakes code to make it faster and more efficient, but it will take time, so be patient.
Want to sumbit your own AI? View our docs.