DevBlog 5 - Multiplayer

Hello and welcome to the fifth CardLife DevBlog,

I'm Ed, also a coder, and - as Rich is still away - it's my turn to write this week's blog. Since we had started developing the core technologies, my main role has been to develop the networking for the multiplayer aspect of CardLife.

Online Multiplayer

A few weeks ago we had a demo running with several players who could see each other running around. Since then I have been getting terrain able to be edited collaboratively by multiple players at once. There are several constraints that this technology must satisfy:

One thing we immediately decided was that the server must be in control of the terrain, and tell players when the terrain is changed by a player. Otherwise, you could end up with different players seeing different modifications to the terrain if they get out of sync with each other.

Secondly we want to have a large number of players playing in the same world at once. This means that we need to make sure that the data we send to each player is minimised. One part of the solution is to only send players data about the area of the world that they can currently see. The result of this is that two players who are miles apart will not know straight away about each other's terrain. But if one player starts to travel closer to the other, they will then start being sent the modified data about that area by the server. That means the bandwidth used will not actually change depending on how large the world actually is.

Thirdly we have the (classic) issue of lag. This is not something that is easily solved, and will probably require a combination of multiple solutions. We can help with this just by having the server in charge. That will mean that if one player has a massive ping, at least it will only be that player who suffers, and everyone else will be able to carry on playing. other than that, a lot of the rest of the solution consists of smoothing everything to make the game still playable.

Whenever I think about writing about networking, I'm faced with one sad fact: unfortunately, multiplayer does not by itself add anything visually nice to the game. So instead of showing a screenshot, I will tell you an example about what interesting experiences can be had once we get multiplayer working:

Rich and I were testing out multiplayer terrain editing, and it quickly turned into an emergent battle between us - each of us trying to be the first to humiliate the other by building a cave around them and blocking them in. Rich thought he was getting pretty good at this minigame and had nearly trapped me - but he hadn't realised we could also dig! So, needless to say, I bluffed for a few seconds, before digging my way out and removing the ground from beneath him as he was running away - causing him to embarrassingly fall into a bottomless pit of doom!

That's just one example that shows what could be possible once we get multiplayer into the game. More news will come later once the technology starts getting closer to being ready!