{"id":3809,"date":"2015-06-12T07:38:42","date_gmt":"2015-06-12T07:38:42","guid":{"rendered":"http:\/\/www.lifeandnews.com\/articles\/?p=3809"},"modified":"2016-09-02T23:36:48","modified_gmt":"2016-09-02T23:36:48","slug":"totally-addicted-to-apps-difficulty-makes-candy-crush-so-sweet","status":"publish","type":"post","link":"https:\/\/www.lifeandnews.com\/articles\/totally-addicted-to-apps-difficulty-makes-candy-crush-so-sweet\/","title":{"rendered":"Totally addicted to apps: difficulty makes Candy Crush so sweet"},"content":{"rendered":"<p><a href=\"http:\/\/theconversation.com\/profiles\/toby-walsh-51\">Toby Walsh<\/a><em>, <a href=\"http:\/\/theconversation.com\/institutions\/nicta\">NICTA<\/a><\/em><\/p>\n<p>It\u2019s been said that in a city, you\u2019re never more than <a href=\"http:\/\/www.bbc.com\/news\/magazine-20716625\">two metres<\/a> away from a rat. But it seems more likely that you\u2019re never more than two metres from someone playing the puzzle game <a href=\"https:\/\/king.com\/#!\/play\/candycrush\">Candy Crush Saga<\/a>.<\/p>\n<p>One possible reason that Candy Crush is so addictive has been revealed in my <a href=\"http:\/\/arxiv.org\/abs\/1403.1911\">recent proof<\/a> which shows that it is a mathematically hard puzzle to solve, thus joining the ranks of puzzles such as <a href=\"http:\/\/minesweeperonline.com\/\">Minesweeper<\/a>, <a href=\"http:\/\/www.sudoku.com\/en\">Sudoku<\/a> and <a href=\"http:\/\/www.tetris.com\/\">Tetris<\/a> which have also been proved to be mathematically hard to solve.<\/p>\n<p>Candy Crush is currently the <a href=\"http:\/\/www.insidefacebook.com\/2014\/03\/03\/top-25-facebook-apps-march-2014-inside-candy-crush-sagas-dominance\/\">most popular game<\/a> on Facebook and it\u2019s been downloaded and installed more than half a billion times. Its developer, <a href=\"https:\/\/king.com\/\">King.com Ltd<\/a>, is soon to list on the New York Stock Exchange in an initial public offering <a href=\"http:\/\/www.bloomberg.com\/news\/2013-10-02\/-candy-crush-maker-king-said-to-file-for-u-s-public-offering.html\">predicted<\/a> to value the company at more than US$5 billion.<\/p>\n<p>That\u2019s not bad for a simple game of swapping candies to form chains of three or more identical candies.<\/p>\n<p>So how do we go about proving that a puzzle such as Candy Crush is hard to solve? What makes noughts and crosses easy, but Candy Crush hard?<\/p>\n<h2>Deduction from reduction<\/h2>\n<p>To prove that Candy Crush is hard, we need to call upon one of the most important and beautiful concepts in the whole of computer science: the idea of a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Reduction_(complexity%29\">problem reduction<\/a>. This is the idea of mapping one problem into another. Or as computer scientists like to say, you reduce one problem into another.<\/p>\n<figure class=\"align-right zoomable\"><a href=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43693\/area14mp\/z35tp3d6-1394596943.jpg\"><img src=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43693\/width237\/z35tp3d6-1394596943.jpg\" alt=\"\" \/><\/a><figcaption><span class=\"attribution\"><a class=\"source\" href=\"http:\/\/www.flickr.com\/photos\/12810816@N08\/11231983986\/sizes\/l\/\">JuhaOnTheRoad\/Flickr<\/a>, <a class=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/4.0\/\">CC BY-NC-SA<\/a><\/span><\/figcaption><\/figure>\n<p>Now, if the problem you started with was hard, then the problem you map into must be at least as hard. The second problem can\u2019t be easier as you can solve the first problem with a program that can solve the second. And if you can show the reverse, that the second problem can be reduced to the first, then the two problems are equally as hard.<\/p>\n<p>In the case of Candy Crush, we started with the most famous class of computationally hard problems \u2013 problems in a class called \u201cNon-deterministic Polynomial-time\u201d (<a href=\"http:\/\/en.wikipedia.org\/wiki\/NP-hard\">NP<\/a>). This class contains all the problems that computer scientists believe are on the boundary between hard and easy.<\/p>\n<p>Beneath NP, we have the problem class P that contains all the easy problems such as sorting a list or finding a record in a database. The time it takes for an efficient computer program to solve such problems is small, even in the worst case.<\/p>\n<p>Mathematically, the runtime (the length of time a program takes to run) is a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Polynomial\">polynomial<\/a> (consisting just of terms multiplied together) of the size of the problem.<\/p>\n<p>Above NP, we have really hard problems. There are even problems above NP for which there is no computer program which is guaranteed to stop and return an answer. You may wait for ever and still not have an answer.<\/p>\n<p>NP, on the other hand, is right at the boundary between easy and hard. Within NP, we have many challenging problems such as the problem of routing trucks to deliver parcels, rostering staff in a hospital, or scheduling classes in a school. Any of these problems can be reduced to any other of these problems. They\u2019re all equally as hard as each other.<\/p>\n<figure class=\"align-left zoomable\"><a href=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43699\/area14mp\/qvyv76xj-1394600210.jpg\"><img src=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43699\/width237\/qvyv76xj-1394600210.jpg\" alt=\"\" \/><\/a><figcaption><span class=\"attribution\"><a class=\"source\" href=\"http:\/\/www.flickr.com\/photos\/mit-libraries\/3441316899\/sizes\/l\/\">MIT-Libraries\/Flickr<\/a>, <a class=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-nd\/4.0\/\">CC BY-ND<\/a><\/span><\/figcaption><\/figure>\n<p>The best computer program that we have for any problem in NP has a runtime that grows dramatically as we increase the size of the problem.<\/p>\n<p>On my desktop computer, I have a program that takes a few hours to find the optimal routing for ten trucks and demonstrate that this was the best that can be possibly achieved.<\/p>\n<p>But for 100 trucks, the same program would take more than the lifetime of the universe. Mathematically, the runtime of my program is an exponential of the size of the problem.<\/p>\n<h2>Deciding between \u2018easy\u2019 and \u2018hard\u2019 is, um, hard<\/h2>\n<p>Surprisingly, while computer scientists believe problems in NP are on the boundary between easy and hard, they don\u2019t actually know on which side they are.<\/p>\n<p>The best computer programs we have take exponential time to solve problems in NP. But we don\u2019t know if there\u2019s some exotic algorithm out there that will solve problems in NP efficiently\u00a0\u2013\u00a0and by efficiently, we mean in polynomial time.<\/p>\n<p>In fact, this is one of the most important open problems in mathematics today, the famous <a href=\"http:\/\/en.wikipedia.org\/wiki\/P_versus_NP_problem\">P=NP<\/a> question. The <a href=\"http:\/\/www.claymath.org\/\">Clay Mathematics Institute<\/a> has even offered a US$1 million prize for the answer to this question. The <a href=\"http:\/\/www.claymath.org\/millennium-problems\/millennium-prize-problems\">prize<\/a> remains unclaimed since it was first offered in 2000.<\/p>\n<p>The idea of problem reduction is central to the P=NP question. If we did find an algorithm that could solve any problem in NP efficiently then, by exploiting the idea of problem reduction, we could solve all problems in NP efficiently. The world would be a very different place if this ever happened.<\/p>\n<p>On the plus side, we\u2019d be able to go about our lives more efficiently, routing trucks, timetabling flights, and rostering staff to save money, but the absence of efficient algorithms to do various tasks such as crack codes is also required to keep our passwords and bank accounts secure.<\/p>\n<figure class=\"align-center zoomable\"><a href=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43694\/area14mp\/vnc7w736-1394597251.jpg\"><img src=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43694\/width668\/vnc7w736-1394597251.jpg\" alt=\"\" \/><\/a><figcaption><span class=\"attribution\"><a class=\"source\" href=\"http:\/\/www.flickr.com\/photos\/symic\/4323860889\/sizes\/l\/\">Symic\/Flickr<\/a>, <a class=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">CC BY-SA<\/a><\/span><\/figcaption><\/figure>\n<h2>Hard candy<\/h2>\n<p>Anyway, let\u2019s go back to Candy Crush. To show that Candy Crush is a hard problem, we could reduce from any problem in NP. But to make life simple, we start from the granddaddy of all problems in NP: finding a solution to a logical formula.<\/p>\n<p>Mathematically, this is called the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Boolean_satisfiability_problem\">satisfiability problem<\/a>. You will have solved such a problem if you ever tackled a logic puzzle. You have to decide which propositions to make true, and which to make false, in order to satisfy some logical formulae.<\/p>\n<p>We created a collection of candies where the player has choices as to which chains to create. And these choices have knock-on effects that mirror exactly the knock-on effects of the choices in deciding which propositions in a logical formula to make true.<\/p>\n<figure class=\"align-right zoomable\"><a href=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43656\/area14mp\/qbhjsb7f-1394587475.jpg\"><img src=\"https:\/\/62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com\/files\/43656\/width237\/qbhjsb7f-1394587475.jpg\" alt=\"\" \/><\/a><figcaption><span class=\"attribution\"><a class=\"source\" href=\"http:\/\/www.flickr.com\/photos\/28154346@N07\/8191590816\/sizes\/l\/\">faseextra\/Flickr<\/a>, <a class=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">CC BY-SA<\/a><\/span><\/figcaption><\/figure>\n<p>We also showed the reverse \u2013\u00a0that is, you can reduce a Candy Crush problem to satisfying a logical formula. Hence, Candy Crush is no harder than any of the problems in NP. Candy Crush is equally as hard as solving all the other problems in NP.<\/p>\n<p>If we had an efficient way to play Candy Crush, the we would have an efficient way to route trucks, roster staff or schedule classes. Equally, if we had an efficient way to way to route trucks, roster staff, or schedule classes then we would have an efficient way to play Candy Crush. That\u2019s the power of a problem reduction.<\/p>\n<p>So, next time you fail to solve a Candy Crush board in the given number of swaps, you can console yourself with the knowledge that it was a mathematically hard problem to solve. Just as hard, in fact, as the staff rostering problem your boss actually wanted you to solve instead of playing Candy Crush.<\/p>\n<p>Finally, there\u2019s an intriguing possibility that may appeal to Candy Crush addicts. Can we profit from the millions of hours humans spend solving Candy Crush problems? By exploiting the idea of a problem reduction, perhaps we can hide some practical computational problems within these puzzles?<\/p>\n<p><img loading=\"lazy\" src=\"https:\/\/counter.theconversation.edu.au\/content\/24269\/count.gif\" alt=\"The Conversation\" width=\"1\" height=\"1\" \/><\/p>\n<p><a href=\"http:\/\/theconversation.com\/profiles\/toby-walsh-51\">Toby Walsh<\/a> is Professor, Research Group Leader, Optimisation Research Group at <a href=\"http:\/\/theconversation.com\/institutions\/nicta\">NICTA<\/a>.<\/p>\n<p>This article was originally published on <a href=\"http:\/\/theconversation.com\">The Conversation<\/a>.<br \/>\nRead the <a href=\"http:\/\/theconversation.com\/totally-addicted-to-apps-difficulty-makes-candy-crush-so-sweet-24269\">original article<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Toby Walsh, NICTA It\u2019s been said that in a city, you\u2019re never more than two metres away from a rat. But it seems more likely that you\u2019re never more than two metres from someone playing the puzzle game Candy Crush Saga. One possible reason that Candy Crush is so addictive has been revealed in my [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":7722,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[28],"tags":[],"_links":{"self":[{"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/posts\/3809"}],"collection":[{"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/comments?post=3809"}],"version-history":[{"count":2,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/posts\/3809\/revisions"}],"predecessor-version":[{"id":7723,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/posts\/3809\/revisions\/7723"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/media\/7722"}],"wp:attachment":[{"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/media?parent=3809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/categories?post=3809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lifeandnews.com\/articles\/wp-json\/wp\/v2\/tags?post=3809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}