{"id":3942,"date":"2020-01-25T00:01:20","date_gmt":"2020-01-25T08:01:20","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=3942"},"modified":"2021-06-06T19:15:59","modified_gmt":"2021-06-07T02:15:59","slug":"hunt-the-wumpus","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=3942","title":{"rendered":"Hunt the Wumpus"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2020\/01\/wumpus-150x150.png\" alt=\"Original Wumpus artwork\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-3946\" \/><br \/>\nThe game <em>Hunt the Wumpus<\/em> isn&#8217;t difficult to code in C. In fact, all you need do is start with the basic number-guessing game presented in <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3940\">last week&#8217;s Lesson<\/a> and you can build just about any text-mode game. That&#8217;s what I did when I started my own C language version of <em>Hunt the Wumpus<\/em>.<br \/>\n<!--more--><br \/>\nHistorically speaking, <em>Wumpus<\/em> was one of the first (if not the first) best-selling computer game. Written by Gregory Yob in 1973, it was was available for the various microcomputers of the era. In fact, I recall a version available for my ancient TRS-80 Model III, which I purchased in 1982. (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Hunt_the_Wumpus\" rel=\"noopener noreferrer\" target=\"_blank\">Wikipedia Entry, <em>Hunt the Wumpus<\/em><\/a>)<\/p>\n<p>The game is text-based. You read a description and type commands based on the description. In this game, the player is trapped in a cave or labyrinth of rooms. Each room is connected to three other rooms. The player moves between the rooms in an effort to hunt and kill the mysterious wumpus.<\/p>\n<p>In addition to the wumpus, the labyrinth is populated with two giant bats and two bottomless pits. Entering a room with a bat causes the bat to lift you up and fly you to another, empty room in the labyrinth. Entering a room with a bottomless pit causes you to die, ending the game. If you&#8217;re unfortunate to enter a room with the wumpus, you&#8217;re eaten and, of course, die.<\/p>\n<p>Fortunately, the game provides feedback when you&#8217;re near a room with the wumpus, a bat, or a pit. Here&#8217;s the text output:<\/p>\n<p>If a bat is in a nearby room, the message is: <em>You hear a rustling<\/em>.<br \/>\nIf a bottomless pit is in a nearby room, the message is: <em>You feel a cold wind blowing from a nearby cave<\/em>.<br \/>\nIf the wumpus is nearby, the message is: <em>You smell something terrible nearby<\/em>.<\/p>\n<p>Upon sensing the wumpus, you can fire an arrow into one of the three rooms. If you guess the room correctly, the wumpus is killed and you win the game. If you guess incorrectly, the wumpus has a 75-percent chance of fleeing to another random room in the labyrinth.<\/p>\n<p>Programmer Yob designed the labyrinth to be more interesting than the grid patterns of early computer games. He chose a layout based on a dodecahedron, or 12-sided shape (Figure 1). The rooms are still interconnected, so it&#8217;s possible to navigate forward and background through the rooms in a predictable manner.<\/p>\n<div id=\"attachment_3958\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3958\" src=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2020\/01\/Dodecaedro_desarrollo.gif\" alt=\"Dodecahedron animation\" width=\"400\" height=\"400\" class=\"size-full wp-image-3958\" \/><p id=\"caption-attachment-3958\" class=\"wp-caption-text\">Figure 1. Animation of a dodecahedron, stolen from Wikipedia. The rooms in the <em>Wumpus<\/em> labyrinth are based on the shape&#8217;s vertices.<\/p><\/div>\n<p>The original <em>Hunt the Wumpus<\/em> was written in BASIC, which was common in the early days of computing. I vaguely remember playing it back back then, though it&#8217;s simplistic and gets old quickly. Still, <em>Wumpus<\/em> provided the basis for other, more complex and involved text-mode games, such as <em>Adventure<\/em> and <em>Zork<\/em>.<\/p>\n<p>Based on the information I provided in this Lesson, you could begin coding your own version of <em>Hunt the Wumpus<\/em>. The details presented were all I started out with. Of course, coding the game took a while, mostly to work out the bugs, but also to re-think my approach several times. I cover the specifics in <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3956\">next week&#8217;s Lesson<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A classic text game from the early days of computing is easy to recreate in the C language. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3942\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3942","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3942"}],"version-history":[{"count":10,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3942\/revisions"}],"predecessor-version":[{"id":4818,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3942\/revisions\/4818"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}