Today I improved my
Replay Validator and it's so useful that I want to talk about it here.
The game has Replay System. Replays have
only the inputs, they know nothing about the physics or the game.
Every replay works same everytime, everywhere because game is fully
deterministic.
However replays would
desync if someone changes the physics is his client with Cheat Engine and submit replays, or I do a gameplay changing update.
Reason is that the player recorded the replays with old physics and now same inputs don't simulate exactly the same gameplay. That's called
desyncing.
When you have game with Leaderboards, there will be cheaters around. And they have so many ways to cheat. You have a secure server, you protected it. You protected the messaging and false data submitting. But still there is Cheat Engine and it's million tricks. So even if you secured your server,
they can submit very low times to get high on the leaderboard.
What I could do thanks to the
Replay System I implemented is, making a
Replay Validator!
BENEFITS OF REPLAY SYSTEM:- Players enjoy the game a lot more, they learn and improve by watching.
- A new player who finishes the level in 3 mins can't say that #1 player who has only 3 seconds is cheating. But he will do a big "WOW".
- Found a bug? Just play the level once in a way bug would trigger, then you can reproduce that ultra rare case by simply watching the replay.
- Not sure if something runs as it should? Record it and slow the replay to 0.01X to make sure.
- Now you can implement your Replay Validator!
BENEFITS OF REPLAY VALIDATOR:- Did a change in code but not sure if you broke something? Just run the validator and see if any of replays are desyncing.
- I don't need to wipe all the leaderboards when I do a change, because most of them still work, validator can correct the good ones and remove the very broken ones.
- Someone sent a replay with 1 second time? It will be caught when validator checks it.
IMPLEMENTATION:I simply started making a bot which
- Opens the game
- Go to levels list
- Open leaderboard of the first level
- Watch #1 player's replay
- If timer went a lot higher than the entry, it's a broken replay which can't finish the level. Note this as a broken replay.
- If replay ended nicely but timer shows a different time than entry, then it's a broken replay but it runs fine. Note this replay as good and update entry time with the time that timer shows.
- If replay ended nicely and the timer shows exactly the same time as entry, then note this replay as good.
- Watch repeat until #10 is watched
- Open the next level's leaderboard
- Repeat this for every level
- Mark the verification status of the replays so verified ones won't be checked on the next run.
This was working really fine. But it takes incredibly long time to watch 10 replays of 80 levels. Lets say 15 seconds each replay, it makes 12000 seconds which is
200 minutes. That's way
too long.
Just because I coded the game using
Fixed timestep pattern, I was able to run the game as fast as I can without syncing it to the real time. Time shortened a lot because each replay ends very quickly.
This is how it looks like.If you look closely, you'll notice that it could be even faster. How? Just close the game window and don't render anything. Whole game will run on the console, you don't need to see anything. Wanna go even further? Remove all the visual updates like particles and effects, disable everything which doesn't affect the gameplay.
And bam, it's now just a simulation, math and physics calculations. It will still run
100% correct as it is normally. Whole validation takes
2-4 minutes max when you need to check all of the replays. But as I wrote before, you mark the verified ones so they are being
skipped instantly, no need to check again.
And here is an example output of the Replay Validator, after a gameplay change I did.I
strongly recommend having a similar system. Thanks for reading, I hope it's useful for you.