{"id":9535,"date":"2016-09-13T18:07:59","date_gmt":"2016-09-13T16:07:59","guid":{"rendered":"https:\/\/informatica.uniurb.it\/triennale\/?p=9535"},"modified":"2016-09-14T12:03:00","modified_gmt":"2016-09-14T10:03:00","slug":"treasurehuntbot","status":"publish","type":"post","link":"https:\/\/informatica.uniurb.it\/triennale\/treasurehuntbot\/","title":{"rendered":"Implementing a bot-based treasure hunt game"},"content":{"rendered":"<p>On August 26th, during the course of the \u201cCoding in your Classroom, Now!\u201d summer school, a large <strong>treasure hunt game<\/strong> took place in the historical center of Urbino:\u00a0<strong>26<\/strong> groups, composed of <strong>139<\/strong> participants overall, challenged each other by chasing clues through the narrow and steep streets of the city, following the orders of a\u2026 <strong>bot<\/strong>.<\/p>\n<p>The game had been developed during the week just before the event and the whole team behind the treasure hunt\u00a0spent the last minutes before the start feverishly fixing the last bugs. (Well, most of them.)<\/p>\n<p>The summer school, aimed at school teachers of all grades, had the main focus of bringing coding to the classroom, in a way that could be engaging for both teachers and young students.\u00a0Thus, it made more than sense that the treasure hunt itself, \u201c<a title=\"Urbino Code Hunting event\" href=\"http:\/\/codemooc.org\/urbino-code-hunting\/\">Urbino Code Hunting<\/a>\u201d as it was called, would be based on coding puzzles as well.<\/p>\n<p><!--more--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-9540\" src=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration-1024x398.jpg\" alt=\"Treasure hunt bot, registration\" width=\"1024\" height=\"398\" srcset=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration-1024x398.jpg 1024w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration-300x117.jpg 300w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration-210x82.jpg 210w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration-290x113.jpg 290w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration-450x175.jpg 450w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-registration.jpg 1927w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>What made the treasure hunt interesting is that the whole registration process, the actual hunting, puzzling, and other game mechanics were directly handled by a <a title=\"@treasurehuntbot\" href=\"https:\/\/telegram.me\/treasurehuntbot\">Telegram bot<\/a>. Anyone with a Telegram account could very easily register during the 4 days before the game just by entering a conversation with it.<\/p>\n<h4>Registrations to the game were handled by a run of the mill conversation with the bot.<\/h4>\n<p>The bot asked registrants to solve\u00a0a \u201cpreliminary\u201d puzzle (to prepare players for what would have come later and to work as some kind of <em>captcha<\/em>), how many other participants would have taken part to the game together\u00a0with the team leader, and the team\u2019s name.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-9538\" src=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map-1024x529.jpg\" alt=\"Urbino Code Hunting map\" width=\"1024\" height=\"529\" srcset=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map-1024x529.jpg 1024w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map-300x155.jpg 300w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map-210x109.jpg 210w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map-290x150.jpg 290w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map-450x233.jpg 450w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-map.jpg 1616w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Usually a treasure hunt game requires players to find hidden objects or reach secret locations based on some\u2014more or less vague\u2014clues. In our case, the actual puzzling was\u00a0centered around coding questions delivered by the bot, not around recognizing locations from clues, both because coding was\u00a0the theme of the game and because many participants weren&#8217;t familiar with the city. Therefore,\u00a0locations to reach were given out explicitly by the bot.<\/p>\n<p>The actual <strong>gameplay<\/strong>\u00a0was\u00a0structured\u00a0as follows:<\/p>\n<ul>\n<li>1) Each group gets a random location to reach (sent as a <a href=\"https:\/\/core.telegram.org\/bots\/api#sendlocation\">precise geographical location<\/a>\u00a0and rendered as a point on a map).<\/li>\n<li>2) On reaching its assigned location, the group snaps a <em>selfie<\/em> and sends it to the bot.<\/li>\n<li>3) The bot picks one of the coding puzzles and waits for the group&#8217;s answer. The bot forces a minimum delay of 1 minute\u00a0between attempts.<\/li>\n<li>4) If the solution is correct, the bot gives out a new clue for the <strong>final puzzle<\/strong>.<\/li>\n<li>5) Go to 1.<\/li>\n<\/ul>\n<p>We identified <a href=\"https:\/\/saveriodelpriori.carto.com\/viz\/a259edfe-6ba0-11e6-86b1-0e233c30368f\/public_map\">30 well-distributed locations around the town<\/a>, which we marked with a description, a precise GPS location, a numeric ID, and a secret code (16 random alphanumeric characters).<\/p>\n<h4>Each location had\u00a0its own secret 16-character code.<\/h4>\n<p>How did\u00a0the bot ensure that a group has reached its destination? Easy. We printed 30 paper signs (on A4 sheets), one for each location, with a special QR Code linking to an URL following this scheme:<\/p>\n<pre>https:\/\/telegram.me\/treasurehuntbot?start=0123456789ABCDEF<\/pre>\n<p>This link makes use of the <a href=\"https:\/\/core.telegram.org\/bots#deep-linking\"><em>deep linking<\/em> feature<\/a> of Telegram: after opening the URL through a QR Code scanner, the user&#8217;s phone automatically starts the Telegram client and sends the \u201c<code>\/start 0123456789ABCDEF<\/code>\u201d string to our bot, without actually displaying it inside the conversation screen. Since each\u00a0QR Code contained the location\u2019s\u00a0secret\u00a016-character code inside the URL, the bot would\u00a0know with certainty which code the group had\u00a0scanned and thus which location was reached.<\/p>\n<p>The bot tracked\u00a0each group making its way through a sequence\u00a0of 12 locations. To ensure that groups of players do not follow each other and that they don&#8217;t cluster in the same area, the\u00a0sequence of locations to reach for each group was\u00a0chosen at random.<\/p>\n<h4>In order to ensure fairness, sequences of locations were generated beforehand with a bounded maximum (and minimum) length.<\/h4>\n<p>Puzzles\u2014which were\u00a0given out as soon as a group reached a location and sent\u00a0a confirmation <em>selfie<\/em> of the group\u2014were\u00a0based on the <a href=\"http:\/\/codemooc.org\/codyquiz\/\">CodyRoby quizzes<\/a> .\u00a0These simple logical puzzles make use of shared conventions, like the colored pseudo-code blocks from <em>Blockly<\/em> used in Code.org and the <a href=\"http:\/\/codeweek.it\/lm09-codyroby\/\">CodyRoby coding cards<\/a> .<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-9541\" src=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091-200x300.png\" alt=\"Sample CodyRoby quiz\" width=\"200\" height=\"300\" srcset=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091-200x300.png 200w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091-683x1024.png 683w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091-210x315.png 210w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091-290x435.png 290w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091-450x675.png 450w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game-telegram\/quiz0091.png 2000w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Sample question.<\/em><\/p>\n<p>All puzzles required at most a couple of minutes to be solved and the answer could\u00a0be provided as a simple text message, usually with a single character or a single number.\u00a0Answers would be\u00a0accepted quite liberally, with whitespace, in upper or lower\u00a0case, and with any formatting. Wrong answers caused\u00a0a forced delay of 60 seconds before the next attempt.<\/p>\n<p>Correct answers not only let the group move forward, but they also rewarded the group with an important clue that would then\u00a0be used to solve the last riddle: as soon as a group reached the last location (which we made sure was the same for all groups), they were\u00a0given a map (like, a real, tangible, honest to goodness map made out of paper) that could\u00a0be used to find out\u00a0the exact place where the coveted prize was\u00a0hidden.<\/p>\n<p>The first group that reached it would get to keep the prize and receive\u00a0another wonderful QR Code. Who doesn&#8217;t love QR Codes anyway? This last code signaled\u00a0that the game was\u00a0over for everyone.<\/p>\n<h4>A Telegram channel was\u00a0used to broadcast information, to share <em>selfies<\/em>, and to make the game more engaging.<\/h4>\n<p>The <a href=\"https:\/\/telegram.me\/urbinocodehunting\">Urbino Code Hunting Telegram channel<\/a> was created on the day of the game and all participants were invited to subscribe to it. Major advancements of the groups were broadcast on the channel, along with all <em>selfies<\/em> taken by the groups as soon as they were sent in from the various locations.\u00a0The channel gave the participants and us a way to monitor the state of the game, thus making it more engaging as the groups got closer to their final destination.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-9536\" src=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-collage-1024x683.jpg\" alt=\"Urbino Code Hunting selfie collection\" width=\"1024\" height=\"683\" srcset=\"https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-collage-1024x683.jpg 1024w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-collage-300x200.jpg 300w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-collage-210x140.jpg 210w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-collage-290x193.jpg 290w, https:\/\/informatica.uniurb.it\/triennale\/wp-content\/uploads\/post\/implementing-a-bot-based-treasure-hunt-game\/treasurehuntbot-collage-450x300.jpg 450w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Part\u00a0of all the selfies collected by the bot.<\/em><\/p>\n<p>The bot was powered by a PHP program and a MySQL database, patched together in less than a week. The source code has been <a href=\"https:\/\/github.com\/CodeMOOC\/TreasureHuntBot\">published on Github<\/a> under the MIT license if you want to take a look. At the moment, deploying the bot for your own backyard treasure hunt might not be the easiest of tasks, but we are already planning to make\u00a0it reusable at will.<br \/>\n<strong>(And we have other significant\u2014and scary?\u2014plans for the future\u2026)<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>On August 26th, during the course of the \u201cCoding in your Classroom, Now!\u201d summer school, a large treasure hunt game took place in the historical center of Urbino:\u00a026 groups, composed of 139 participants overall, challenged each other by chasing clues through the narrow and steep streets of the city, following the orders of a\u2026 bot.&hellip;<\/p>\n","protected":false},"author":43,"featured_media":9537,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[151],"tags":[1611,460,1613],"post_series":[],"class_list":["post-9535","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lablog-en","tag-bot-en","tag-coding","tag-telegram-en","entry","has-media"],"acf":[],"_links":{"self":[{"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/posts\/9535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/comments?post=9535"}],"version-history":[{"count":10,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/posts\/9535\/revisions"}],"predecessor-version":[{"id":9561,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/posts\/9535\/revisions\/9561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/media\/9537"}],"wp:attachment":[{"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/media?parent=9535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/categories?post=9535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/tags?post=9535"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/informatica.uniurb.it\/triennale\/wp-json\/wp\/v2\/post_series?post=9535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}