Dev diary

3 min read

How our online cricket game will decide every ball

We're building an authoritative match server: your phone sends what you did, the server decides what happened. Here's the plan and why it keeps matches fair.

NPL Cricket League teamRead in Nepali
How our online cricket game will decide every ball
In this story
  1. The idea: your phone sends inputs, not results
  2. How a ball will be decided
  3. Matchmaking, with Lumi AI as a fallback
  4. Fairness beyond the scoreboard
  5. The online cricket game stack

When you play someone online, you need to trust that the score is real. That's why the most important piece of our online cricket game isn't something you'll ever see. It's the match server, and we're designing it so that it, not your phone, decides every ball. Here's how that will work.

The idea: your phone sends inputs, not results

In a lot of mobile games, each phone works out what happened and reports the result. That's simple, but it means a modified phone could report whatever it likes.

We're taking the other route. In NPL Cricket League, your phone will only send what you did:

  • Batting: your shot, the direction and strength of your swipe, your timing and your footwork.
  • Bowling: your delivery type, where you aimed it, and the rhythm of your run-up.

The server takes those inputs and works out the outcome. Then it sends the same result to both players at the same moment. Neither phone gets a vote on the score.

No phone decides its own score. The server decides, and both players see the same ball.

How a ball will be decided

Every delivery is a meeting of two sets of choices. The bowler picks a type and a target. The batter reads it and responds. The server will weigh all of it:

  • Line and length. Where the ball pitched, and whether it was on the stumps, wide of off, or short.
  • Timing. How close the batter's swing was to the moment the ball reached the bat.
  • Footwork. Whether the batter went forward to a full ball or back to a short one.
  • Player skill. Each fictional player has attributes such as timing, power, technique, pace, accuracy and spin, and those will shape the outcome too.

A good-length ball met with the right foot and good timing should go a long way. A yorker met late should hit the stumps. The goal is that results always make cricket sense, and that you can learn from them.

The simulation is designed to run in fixed time steps, so the same inputs will lead to the same physics on any phone. That matters for fairness, and it matters for replays.

Matchmaking, with Lumi AI as a fallback

Finding an opponent is the other half of online play. Our plan is skill-based matchmaking for quick matches of 2 or 5 overs, ranked or unranked, so you're paired with someone at your level.

Sometimes nobody at your level will be free. Rather than leave you staring at a spinner, Lumi AI, our computer opponent, will step in after a short wait. Lumi AI is also planned to hold your seat if your connection drops mid-match, so a bad signal doesn't hand the game away. It adapts to your level, so it should be a challenge without being unfair.

Fairness beyond the scoreboard

An authoritative server is the foundation, but fairness is wider than that. Here's what we're committing to:

  • No pay-to-win. The plan is a free game with cosmetics only. Money will never buy you runs, wickets or better players.
  • Rate limits on the server, so nobody can flood it with inputs.
  • Reports and moderation in our admin tools, so problems can be handled by people.

The online cricket game stack

For the technically curious: the match server we're building runs on Node, with Socket.IO keeping both players connected to the same match in real time, MongoDB for accounts, squads and match history, and Redis for matchmaking queues, who's online and rate limits.

This isn't our first go at server-decided cricket. Our Game Collection app already ships a broadcast-style cricket game with outcome logic on the server, and those lessons are the starting point here.

The live match server is planned for phase 3 of our roadmap, and the game is in development for iOS and Android. We'll write more as it comes together.

NPL Cricket League is a game by Lacspace inspired by Nepal's T20 franchise cricket. Team names identify the franchises; crests, kits and players in the game are our own, and players are fictional. It is not affiliated with, endorsed by or licensed by the Cricket Association of Nepal, the Nepal Premier League or its franchises.

  • #server
  • #fair-play
  • #matchmaking
  • #lumi-ai
  • #dev-diary