Non-deterministic algorithms explained using Stadia State Share

 One of the big open questions in computer science is known as "P = NP", meaning the question of whether (the default deterministic) Polynomial algorithms can solve the same problems as Non-deterministic Polynomial algorithms. We computer scientists are lazy fuckers who compress 40 letters into 2. Countless hours has gone into not just the research on this, but also on just wrapping your head around what "non-deterministic algorithms" really means. An algorithm is just an extremely detailed recipe for doing stuff. Non-deterministic? Does that mean you get to throw dice? Or does it depend on there not being a predetermined fate known only to a higher being? Video games to the rescue!

Stadia has introduced a feature called "State Share", in which you can share not just a screenshot or a video clip, but the entire state of the game that you're playing. Other players who own that game can then pick up from there and keep playing. Maybe later they'll share their state back to you and you can pick it up again. This is of course not really new, copying save games has been a thing since the home computer era, and some games (like NetHack) even go to great lengths to make it impossible to share or even save your game. But making it easy and integrated and online just enables possibilities that were previously impractical. And that's where non-determinism enters the game (pun intended).

Say that you're playing a fiendishly difficult game and you're looking at a particular nasty spot that you don't think you can easily get through. If you were to just save the game and try over and over again, you'd probably eventually make it through, but it would take you forever. That's the deterministic approach, spend lots of time trying again and again. 

But say that instead you use State Share to upload your problem to Teh Internetz, and your game problem goes viral! Thousands, nay millions of gamers, many way better than you, throw their time at the foul boss monster and its drooling minions. Eventually, one of them make their way through and shares the result with you. How much time did you spend on this? Well, you had to get to that point in the game first - that's just setup. Then the game took some time to go viral and spread widely enough, that's overhead. And finally, there's necessarily the time that it took that one person to make it through and share it back, that's finding the solution. But the time spent by all those other people? Not your time. Essentially, you got the internet to try a gazillion different solutions and only had to spend the time it took to find the one right one (plus some overhead). 

That's how non-deterministic algorithms work, in essence. You have some step with many possible variations, typically exponentially many for the interesting problems like Travelling Salesman. But instead of having to try them all yourself, you magically try all of them in parallel and only have to consider the time it takes for the correct solution. Technically, there's also a step required to check that the solution is correct, which the State Share analogy doesn't capture, except perhaps in that you afterwards continue the game and may find that the successful player had used all your potions and now you can't get through the next part. But that's a detail. You've just harnessed the incredible power of the internet to implement a non-deterministic algorithm and thus get a bit further in your game. Congratulations, computer scientist gamer!

Comments

Popular posts from this blog

My Ikea Hack Workbench

I made 1:1 bread, and it is de-leeecious!

Almond flour isn't just almond flour