{"id":380,"date":"2009-07-28T18:59:25","date_gmt":"2009-07-28T18:59:25","guid":{"rendered":"https:\/\/blogs.mathworks.com\/videos\/2009\/07\/28\/puzzler-rules-of-the-new-game\/"},"modified":"2017-05-30T11:57:05","modified_gmt":"2017-05-30T16:57:05","slug":"puzzler-rules-of-the-new-game","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/videos\/2009\/07\/28\/puzzler-rules-of-the-new-game\/","title":{"rendered":"Puzzler:  Rules of the new game"},"content":{"rendered":"I was playing a game by LabPixies on my iPhone.  I spent more time thinking about programming an optimal solution than anything else while playing.  I decided to give it a try in MATLAB.  After getting some help from the MATLAB community in <a href=\"https:\/\/blogs.mathworks.com\/videos\/2009\/06\/17\/puzzler-find-four-connected-component-to-element-1-of-2-d-matrix\/\">the last puzzler<\/a> I was able to implement a quick running solution.  \r\n<p>\r\n<p>\r\nI am always amazed at the creativity of the MATLAB community, so I am posting all the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/24598-puzzler--supporting-files\">files needed<\/a> so you can implement your own solution.  I have included my solution also, but I recommend not looking until you have tried your own.\r\n<p>\r\n<p>\r\nSince this is a more involved problem, posting to the comments does not seem as reasonable.  Please e-mail me (hull@mathworks.com) your completed code (one file, has everything it needs to run, your contact info in the comments) and I will put together a video covering the best of ideas.  If I use your code or ideas in the video, I will send you a MATLAB t-shirt.\r\n<p>\r\n<p>\r\n<strong>MINOR SPOILER ALERT<\/strong>\r\n<p>\r\nWhat I have discovered is that this program either finds a solution very quickly, or does not find one before I get bored (5 minutes, I should run it overnight&#8230;.).  I take a &#8220;greedy&#8221; approach (selecting the color that will cause the largest change), this is not always optimal.  I am doing an exhaustive search, only looking one move ahead.  This will find a solution if it is possible, but there might be a better way.\r\n\r\n<div><div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"3877437985001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div>\r\n <\/div>\r\n","protected":false},"excerpt":{"rendered":"<div class=\"thumbnail thumbnail_asset asset_overlay video\"><a href=\"https:\/\/blogs.mathworks.com\/videos\/2009\/07\/28\/puzzler-rules-of-the-new-game\/?dir=autoplay\"><img decoding=\"async\" src=\"https:\/\/cf-images.us-east-1.prod.boltdns.net\/v1\/static\/62009828001\/2145a4bb-02c8-4ccc-a0ae-b647d4acea71\/e1f38cd2-de6d-4529-8cd1-8f9b46055f5f\/1280x720\/match\/image.jpg\" onError=\"this.style.display ='none';\"\/>\n      <div class=\"overlay_container\">\n      <span class=\"icon-video icon_color_null\"><time class=\"video_length\">5:11<\/time><\/span>\n      <\/div>\n      <\/a><\/div><p>I was playing a game by LabPixies on my iPhone.  I spent more time thinking about programming an optimal solution than anything else while playing.  I decided to give it a try in MATLAB.  After&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/videos\/2009\/07\/28\/puzzler-rules-of-the-new-game\/\">read more >><\/a><\/p>","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,12,10],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/380"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/comments?post=380"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":3079,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/380\/revisions\/3079"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/media?parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/categories?post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/tags?post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}