Hacker News new | comments | show | ask | jobs | submit login
Determinism in League of Legends: Unified Clock (riotgames.com)
56 points by ingve 12 months ago | hide | past | web | favorite | 21 comments

This is a fantastic article! I built something similar a few years ago, except I couldn't rely on a centralized server. So I had to come up with a P2P/decentralized variant of it.

There is a test page up for it, so you can test it out in practice across multiple devices to see how precise (not accurate) it is: https://gunjs.herokuapp.com/game/nts.html

Turns out the math/algorithm isn't too hard! Less than 50LOC for full implementation: https://github.com/amark/gun/blob/master/nts.js

I recommend you have fun and challenge yourself to solve it first before looking at the code! It made me really understand General Relativity spacetime so much more, it clicked.

The idea of riot games posting an engineering article is funny to me. They're famous among their own players for having a very buggy platform, and handling time between framerates is one of the earlier things you learn in game development.

I find it believable but sad that there were apparently eight different implementations of this idea across the codebase. I am not surprised that the developer had to add an ascii skull and crossbones to his code to encourage others not to change it.

It's easy to point and smirk at the quality of someone else's codebase from a distance. But as a long time player of League, it's been very rare that a software bug has affected my enjoyment of the game. The quality of my internet connection and the state of balance have always been matters with significantly more impact.

I further think that Riot often doesn't get credit for the things they do right. I remember back in the day they were rolling out patches weekly, with a 12 hour maintenance window a la WoW on Tuesdays. That fell to half that time, then a third, and has at this point been gone for years. Cheating is a major problem in any current multiplayer game (PUBG has been getting hit hard recently I hear), but it's never been big enough in League that I felt the effects.

Riot has managed to build the biggest gaming phenomena outside of Minecraft in the last decade, and I'd expect corners to be cut in doing that. Clean code doesn't win a startup race, and games are a cut-throat business (see: Epic's Fortnite rolling out a battle Royale mode in a span of months following the success of PUBG). It's a good thing, imo, that Riot can afford the time and energy to start cleaning their code, and are willing to share some parts of that process with the wider world.

> but it's never been big enough in League that I felt the effects.

Hm... Have you ever played in ARAM? ARAM is mode where you have only one line with 5vs5 players on it. Often it's much shorter than regular Dota, LOL matches but give same "experience points" to buy/open some in game items.

You can encounter farming bots there, they just do one thing : go to enemy and die. It isn't fun to play with them. Once there were 3 bots in one match. Servers were infested with them for weeks it was impossible to play ARAM back then.

Bots and cheating are in a similar category but considered different things. Cheats unfairly enhance a player's ability to raise their rank while bots sell the lowest-level accounts to people who don't want to spend time grinding in-game points (in League's case, IP to buy Champions or Experience Points to hit level 30, the bare minimum to participate in ranked play).

It's not just people sniping at a distance. A former Riot engineer mentioned how frustrating their code was. He has a lot of criticisms, mostly along the lines of shoehorning abstractions inappropriately. His main critique was that they couldn't move nearly as fast as they'd like due to the massive technical debt.

> shoehorning abstractions inappropriately

Riot is infamous for this even among players. A lot of their dev decisions in the past were blatantly "fastest possible answer", including things like building solid terrain out of immortal, un-targetable units to save time.

That said, the criticism feels sort of dated, like they got a bad reputation and it stuck after they caught up to the normal amount of badness for a video game. There are kludges, but they don't show the way they used to.

Huh, I thought I worked at $COMPANY_NAME, but apparently I work at Riot Games.

> They're famous among their own players for having a very buggy platform

lolwut? Back when I used to play LoL, there was almost -zero- bugs in the actual game.

Are you sure you're not confusing this with their shitty Adobe Air client (which does not run the actual game, which is a separate process).

I will append a disclaimer: Have not played LoL in years. So if it has changed, feel free to tell me so.

Lux's ultimate ability used to be (still is?) made of invisible minions.

Mordekaiser at one point in history had over 50 known bugs. (apparently over 200 according to another commenter)

Some champs could walk through Jarvan's ultimate.

There were others but those are the cases that stand out in my memory. I know you'll probably say something like "three bugs? that's nothing!" but I played the game off and on for 6 years from 2009-2015 and there were plenty of examples of stuff like that.

LoL was at minimum distinctively buggy. It wasn't the "gamebreaking bullshit" approach of e.g. Sim City, but it was jarring and frequent. There seemed to be two major problems.

The first was a reliance on kludges in new code (like that Lux ult) - it was the distinctive look of a team trying to put out new features faster than their dev time permitted.

The second was an inability to rely on invariants. Most games can say "X is always true, Y is always true except in case Z" and maintain that even across many and expansions. League (and other MOBAs) relied on putting out new characters with novel, interesting abilities. But that leaves game design and software design in conflict; a major source of novelty is breaking rules other characters share. And so everyone has some silly special case that makes all other development harder, and also reveals the kludges in problem one.

Mordekaiser can copy dead units, so every single unit has to be checked to not break when he does that. Lux ults are made of minions, so every character with a "dash to minion" ability has to be safeguarded against dashing to the ult. And so on, for characters^2 interactions.

Things are vastly better than they used to be, but it's not a surprise the thing got a reputation for bugginess.

I've been playing since Season 3, and there's def been some ridiculous bugs. It's gotten better over time, but the spaghetti code and 'coded as a minion' memes are still just as popular as ever. To be honest I think this is the first time I've seen someone that plays LoL not call it a buggy mess.

My personal favorites are when that update to Skarner broke Lux's ult (how are those related at all?) and when they first added the smite damage to the HUD which broke flash because the UI wasn't designed to display that data (flash's cooldown would get set to smite's damage as it's cooldown, or about 500 seconds early game).


One of their lead champion designers has even come out and said something along the lines that many champion's dashes are coded separately, even though a dash would be something pretty easy to reuse. I'm pretty sure the champion ability scripts are written by the champion designers and not formal engineers/programmer base on comments like this one and others I've seen on reddit from Riot's champion designers.

Crashes and visual glitches are very rare, but there are a lot of bugs that just go unnoticed due to so much stuff happening at any time.

See [0] for the best example, but while now that those are documented it's clear that that's the worst case, a good number of champions contented for the Most Bugged crown over the years, even months after being released or still unfixed to date.

Other than that the new CEF client is still more buggy and unstable than the old one (same guy who made the above list also had one for the client although that hasn't been updated in months AFAIK) and at any time there has always been some sort of bug related to pathing, vision, or targeting.

Also I'm not 100% sure about the last year, but I think there as never been one since at least when I started playing in 2013 when some near-gamebreaking champion bug didn't make it to the "LTS" patch fixed for the LCS.

[0] https://boards.euw.leagueoflegends.com/en/c/bug-reports-eu/a...

LoL is known for being very buggy.

What's even funnier to me is:

1. The concept they're claiming to have spent so much time to arrive at here -- a unified game time clock -- is something that most game engines have always had. This shouldn't be a new concept.

2. Even after they identified that the use of floating-point types for time calculations could cause errors, what does their new API design use as its return types? Float and double. It's almost as though they forgot what the problem was.

I would say this used to be the case but now they've made a significant effort in order to improve reliability. It's not surprising that there's a bunch of old stuff still around.

Just look at how long it took them to implement replay and a sandbox mode. I'm not sure how much of that was design decisions or was simply because of all the old crap they had to get rid of.

> all the old crap they had to get rid of

They were pretty open about this being the issue with sandbox mode. Ostensibly-simple stuff like "set champion level to 7" was a nightmare because the game lacked any easy way to break invariants like "levels increase one at a time based on XP gain obtained in-world".

Well... do you have the same level of fun when you read quite a long discussion on HN about Firefox where people write many interesting things, but no one knows that the abbreviation of Firefox is not FF? Come on.

They also created Berkshelf.

Anywhere else I can read this? Blocked at work

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact