Thursday, November 02, 2017

Entanglement Leader Boards

Entanglement has been online since the summer of 2010 (fun flashback here). Back then, we did a few things right, but in retrospect we did a lot of things wrong. One of those was the leader boards.

We must have a problem with digital hoarding.
Early on, we decided to store every score. Not sure why. We now have approximately 15,000,000 scores. Most of which no one cares about or is even able to see. For perspective, if you were to take 15 million cans of soda and dump them into the Grand Canyon... ...that would be environmentally irresponsible - don't do it.

We also stored a lot of data about each score: the score, the number of line segments, a validity check, the map it was on, the player that made it, the time it was entered, the current temperature in Hickory, NC... know, a lot.

Deciding that keeping 15,000,000 scores indexed in our database is ridiculous, I'm revisiting how the scores are stored. A few years ago, I cleaned things up by dropping all scores below 50 points. I had also connected Google Games at some point to handle scoring, but its implementation in Entanglement was half-baked, so that's currently being rolled back. I've finally settled on another alternative. Rather than storing all the scores ever, it's now storing a single score for today, this week, and all time for each player. This is much more sustainable and makes loading the leader boards a lot more snappy!

This has had the biggest impact on how the Daily Challenge leader board works. It was designed to show the last 7 days of scores. As such, it has been the primary reason score storage hasn't been completely changed up to this point. To make the Daily Challenge work with this new method, it no longer stores leader boards for each day. Rather, it stores today's leader board, and at the end of the day each player is awarded points according to where they placed on that day's final leader board. These points are added to their weekly and all-time scores. The Daily Challenge Champion is awarded 50 points, other players in the top ten are awarded 10 points, and all other players receive 1 point for participation.

I've already run this algorithm on the past 7 years of Daily Challenge scores, so check out the all-time leader board to see a few really good players.