{"id":298,"date":"2006-09-28T20:25:49","date_gmt":"2006-09-28T09:25:49","guid":{"rendered":"http:\/\/www.somethinkodd.com\/oddthinking\/2006\/09\/28\/solitaire-battleships\/"},"modified":"2008-04-13T11:34:16","modified_gmt":"2008-04-13T01:34:16","slug":"solitaire-battleships","status":"publish","type":"post","link":"https:\/\/www.somethinkodd.com\/oddthinking\/2006\/09\/28\/solitaire-battleships\/","title":{"rendered":"Solitaire Battleships"},"content":{"rendered":"<h3>Introducing Solitaire Battleships<\/h3>\n<p>I first saw Solitaire Battleships (also known as &#8220;Fathom It!&#8221;) many years ago about in a <a href=\"http:\/\/www.amazon.com\/exec\/obidos\/ASIN\/0806959568\/o\/qid=957043036\/sr=8-1\/ref=a?tag2=mountainvistasof\">puzzle book<\/a>, but it recently became available on <a href=\"http:\/\/www.conceptispuzzles.com\">Conceptis Puzzles<\/a> too, which was the trigger for this article.<\/p>\n<p>Here&#8217;s an <a href=\"http:\/\/www.reed.edu\/~mcphailb\/applets\/battleships\/\">online implementation<\/a>, with rules, to explore.<\/p>\n<p>Four years ago, I took on Solitaire Battleships as <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/puzzling-over-puzzles\/\">another puzzle<\/a> to solve.<\/p>\n<h3>My Approach<\/h3>\n<p>My approach Solitaire Battleships was a precursor to my very similar approaches to <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/21\/\">Sudoku<\/a>, <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/06\/12\/the-no-nos-and-yes-yeses-of-the-nonogram-solution\/\">Nonograms<\/a> and Kakuro. <\/p>\n<p>Each cell on the grid was represented by an object that maintained a list of possible values it could take (e.g. water, submarine, stern of a vertical battleship), and, when triggered, would compare its list for compatibility with its neighbours, reducing the list until the final solution for that cell was found.<\/p>\n<p>Meanwhile, for each row and column was represented by a Line object which would hold the clue that represented the number of ship segments. When triggered, it would compare its clue to the count of ship objects and unsolved cells. It would detect if the remaining unsolved cells were all ships or all water, and inform the corresponding cells appropriately.<\/p>\n<p>Finally, a Fleet object would track the number of cells that contained, <em>or might contain<\/em> the sterns of each ship type. If the number of definite frigate sterns (for example) equaled the number of frigates in the the fleet, the other &#8220;maybe&#8221; cells were told that they weren&#8217;t frigate sterns. If the number of definite + maybe frigate sterns equalled the number of frigates, the &#8220;maybe&#8221; cell were told that they definitely were frigate sterns.<\/p>\n<h3>The Result<\/h3>\n<p>Like my half-completed Sudoku solution three years later, my implementation of these simple rules didn&#8217;t completely solve any but the simplest of Solitaire Battleship puzzles. I hadn&#8217;t implemented back-tracking as I <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/puzzling-over-puzzles\/\">don&#8217;t see the point<\/a>.<\/p>\n<p>I had expected this, and I structured the system as an aide to human solving. The human could enter a statement about a particular cell, and the system would reapply the constraints until it could solve no more, and then present the new state of the board, for the human to make the next pronouncement.<\/p>\n<h3>NP-Completeness<\/h3>\n<p>Like Sudoku, it was around about this point in the process that I found out that <a href=\"http:\/\/www.mountainvistasoft.com\/docs\/BattleshipsAsDecidabilityProblem.pdf\">Solitaire Battleships is NP-complete<\/a>. The linked paper discusses how this result appears surprising because solving commercially published Solitaire Battleships doesn&#8217;t <em>appear<\/em> to involve guesswork. The authors shows how the puzzles published in newspapers are generated by working backwards from a solution in such a way that simple &#8220;human&#8221; logic can solve it.<\/p>\n<p>This seems to be a similar result to finding <a href=\"http:\/\/en.wikipedia.org\/wiki\/Sudoku\" title=\"Wikipedia definition of Sudoku\" class=\"wikipedia\">Sudoku is NP-complete<\/a>, which seems <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/21\/#comment-824\">somewhat<\/a> <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/21\/#comment-10238\">controversial<\/a> <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/24\/22\/\">amongst<\/a> people who point out that they never backtrack in solving the ones that they see.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My approach Solitaire Battleships was a precursor to my very similar approaches to <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/21\/\">Sudoku<\/a>, <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/06\/12\/the-no-nos-and-yes-yeses-of-the-nonogram-solution\/\">Nonograms<\/a> and Kakuro. <\/p>\n<p>The result seems to be similar to finding <a href=\"http:\/\/en.wikipedia.org\/wiki\/Sudoku\" title=\"Wikipedia definition of Sudoku\" class=\"wikipedia\">Sudoku is NP-complete<\/a>, which seems <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/21\/#comment-824\">somewhat<\/a> <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/21\/21\/#comment-10238\">controversial<\/a> <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/05\/24\/22\/\">amongst<\/a> people who point out that they never backtrack in solving the ones that they see.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"","footnotes":""},"categories":[33,34],"tags":[263,55,54],"class_list":["post-298","post","type-post","status-publish","format-standard","hentry","category-puzzle-solving","category-software-development","tag-computational-complexity","tag-puzzle","tag-solution"],"_links":{"self":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts\/298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/comments?post=298"}],"version-history":[{"count":0,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts\/298\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/media?parent=298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/categories?post=298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/tags?post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}