Making It Multiplayer

The Prince is going to be multiplayer. It is, by its nature, a multiplayer game. This is part of what makes the game work well, but it’s also going to be one of the more challenging aspects of development, at least from my perspective as the coder. And since multiplayer is central, it’s going to need to be in the prototype from the get-go.

Server-side PHP
Actual server-side PHP

Adding multiplayer changes the game from being a complex, interactive application to being a complex, interactive application running on top of a state machine. Any action taken by the local player needs to be sent to the server, and any action taken by the remote player needs to be read from the server. The game is base on time-limited turns, so this back and forth needs to be coordinated throughout the entire game.

Since the game is turn-based, I won’t need to deal with the usual multiplayer difficulties, like serializing packets, using dead reckoning, optimizing my protocol, etc. Instead, I can just use TCP to ensure packet delivery, and structure data into JSON strings. Then my main concerns are for synchronizing time and the getting the logic right.

I don’t have too many implementation specifics to offer yet because it hasn’t been completed. What has been done on the server side was written in PHP with MySQL backing for storage. I realize that going to the DB on every call may not be fast enough in the future, but I’ll cross that bridge when we come to it. In the meantime, it’s familiar, (relatively) easy to work with, and it’s more than enough for these early prototyping days.