The Latency Dilemma
Welcome to my developer log for Cube Wars! I'm already 28 hours in, but I think there will be plenty of challenge for me to write about in the upcoming weeks and months. I would like to ship a fully functional game by sometime in the fall, hopefully when I am settled into college.
I initially decided to create this game for Hack Club's Neighborhood program -- a neat initiative that lets young hackers live in San Francisco making projects for free. Ultimately, I ended up making the difficult decision to not participate after 28 hours of work, but here I am with an unfinished game and some extra time!
I feel like I should talk about something I discovered early on into development since this is my first devlog, so here we go!
Authoritative vs. Responsive
Part of the struggle with building a real-time game is how to juggle between an authoritative model and a responsive model. I want my game state to be controlled entirely on the server to prevent cheating, but I also want the user to feel a snappy input with absolutely no delay.
Most production video games I've played have a solution to this: client-side prediction. Ever notice how in games like Minecraft or Valorant, when you lose connection on a server, you can still move around? And when you reconnect, you teleport back to where the server thinks you're at? That's no surprise.
Prediction and Reconciliation
Client-side prediction is a solution that predicts locally the actions that will be taken by the user BEFORE the server can respond back. Most of the time, these actions are the same; the prediction is correct, and the player notices nothing.
If the prediction is incorrect (e.g., you tried to rotate into a wall that the server knows about but your client didn't yet), the client must snap the piece back into the server's correct position. This is called reconciliation.
In the case of Cube Wars, I'm choosing to include this option, but only after the minimum viable product (MVP) is shipped. I'm still learning this process, and I hope that this summer is enough time for me to complete the MVP.