6 ms·
While looking at the js source code and modifying it a bit I was able to program keys W A S D to move my cell around. But it doesn't work after a bit. The proto
by xana 11y ago
While looking at the js source code and modifying it a bit I was able to program keys W A S D to move my cell around. But it doesn't work after a bit. The protocol is send the position of the mouse (which corresponds to the cell) to the server and then it calculates change over time to get a velocity. So if I move too much it starts going forever in one direction. Although this is using a quad tree implementation for collision detection the actual detection seems to be done on the server side and not the client. There is no websocket message to tell the server if you collided with another cell or if you "ate" some of the material that makes the cell grow. This is actually my goal in "hacking" the game was to pop to different locations to get as big as possible.
Also like everyone else I get connection errors. It's actually quite interesting. It appears this game is load balanced between three or four servers. The script makes a request to http://m.agar.io/?_=<timestamp> http://m.agar.io/?_=<timestamp> which returns the IP of a server used to initiate a websocket. It changes each time you refresh it.
- toxicFork 11y agoOnly sending input? That's great networking design!
- xana 11y agoYeah I know right. No wonder this game crashes. When you press the space bar it sends a message, when you move your mouse it sends a message. The message is in function U() (its the Y position, X position and some other value I've confirmed its not magnitude don't really know what it does). As soon as the connection is established it starts sending, although if you don't move the mouse it doesn't send a message. Then there is a message to update the players view of the game.
- toxicFork 11y agoI wasn't sarcastic! It's actually very good practice...
- xana 11y agoBut wouldn't it be more efficient to calculate the velocity on the client side then only send changes to the vector?
- toxicFork 11y agoIt may be more efficient. But sometimes you should not trust the client ;)
- IkmoIkmo 11y agoAbsolutely, I'm still waiting for my bank to let me modify the money in my account client-side, that way they'll have to do a lot less computing! I swear I'll never send the server anything dishonest, like say owning a billion dollars. :)
- deleted 11y ago[deleted]
- SCHiM 11y agoBut then you'd still be computing the velocity on the server side, only now you're checking if the reported velocity is legitimate or not.
- IkmoIkmo 11y agoExactly. Client-side computing exists, but only to present a fake state which doesn't affect the game mechanics but only servers a cosmetic function to bridge the time until the server updates the client with the actual data (on which any essential game mechanics are based). Games typically just send keyboard input to the server, simulate the game as best they can, and receive the state of the game as it 'really' is. Just like you can't change your money on your bank account, but you can send instructions to send money (keyboard input), and your client-side app will likely immediately update your balance even if it's not fully processed yet by the server. Beyond that, computing vectors of a few players isn't really a big deal for a server, with 20 players you're really running a relatively simple simulation without any rendering. Data on the network is the bottleneck. And it's far more efficient to send e.g. a 'player pressed Forward' on second 0, and 'player released Forward' on second 8. That's two messages, as opposed to a 30-60 frames per second update on the player's position. So for security and performance, it's usually not that great of an idea for clients to do all that much computing. One day we might even see rendering happen serverside, too, OnLive got it to work pretty well at low-res but it was far from optimal. (they shut down btw)
- learnstats2 11y agoHow could you do better than that? It's a real-time game; it needs that much input data (but nothing else).
- Matheus28 11y agoDev here. There are at least 12 servers at the moment, but they're divided between several regions so you're probably only seeing the IPs of the servers in your region. Each server also has several instances of the game, it creates more as demand rises. The most used resource on the servers is CPU.
- deleted 11y ago[deleted]
- Programmer119 11y agoWhere did you find the source code? I have been looking everywhere and cannot find it!
- aerovistae 11y agoUh, by looking at the webpage's source code?