{"id":13942,"date":"2023-03-21T02:41:34","date_gmt":"2023-03-21T01:41:34","guid":{"rendered":"https:\/\/www.graviton.at\/letterswaplibrary\/how-to-build-a-maze\/"},"modified":"2023-03-21T02:41:34","modified_gmt":"2023-03-21T01:41:34","slug":"how-to-build-a-maze","status":"publish","type":"post","link":"https:\/\/www.graviton.at\/letterswaplibrary\/how-to-build-a-maze\/","title":{"rendered":"How To Build A Maze"},"content":{"rendered":"<p>                              HOW TO BUILD A MAZE<\/p>\n<p>          David Matuszek<br \/>\n          Department of Computer Science<br \/>\n          8 Ayres Hall<br \/>\n          University of Tennessee<br \/>\n          Knoxville TN 37916<\/p>\n<p>          Taken from Byte&#8217;s December 1981, page 190 (I only typed a<br \/>\n          part of the article).<\/p>\n<p>\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414\u0414<\/p>\n<p>               Mazes are fun to solve. With a little imagination,<br \/>\n          mazes can be incorporated into many different computer<br \/>\n          games. If you know how, it&#8217;s a simple matter to use the<br \/>\n          computer to generate random mazes.<br \/>\n               A traditional maze has one starting point and one<br \/>\n          finishing point. In addition, all locations inside the maze<br \/>\n          are reachable from the start, and there is one and only path<br \/>\n          from start to finish. While it is easy to place doorways and<br \/>\n          barriers randomly inside a maze, it is more difficult to<br \/>\n          satisfy the two later constraints. This article describes a<br \/>\n          fairly simple method that efficiently produces a random<br \/>\n          traditional maze.<\/p>\n<p>          THE GENERAL APPROACH<br \/>\n               We begin with a rectangular array. Each cell of the<br \/>\n          array is initially completely &#8220;walled in,&#8221; isolated from<br \/>\n          its neighbors (see figure 1).<\/p>\n<p>          \u0419\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u00bb    Secondly, we<br \/>\n          \u0454  \u042a\u0412\u0412\u0412\u0412\u0412\u0457  FIGURE 1                  \u0454  judiciously erase<br \/>\n          \u0454  \u0413\u0415\u0415\u0415\u0415\u0415\u0491                            \u0454  walls inside the<br \/>\n          \u0454  \u0413\u0415\u0415\u0415\u0415\u0415\u0491  The initial array from    \u0454  array until we<br \/>\n          \u0454  \u0413\u0415\u0415\u0415\u0415\u0415\u0491  which the maze will be    \u0454  arrive at a<br \/>\n          \u0454  \u0413\u0415\u0415\u0415\u0415\u0415\u0491  constructed.              \u0454  structure with the<br \/>\n          \u0454  \u0413\u0415\u0415\u0415\u0415\u0415\u0491                            \u0454  following property:<br \/>\n          \u0454  \u0410\u0411\u0411\u0411\u0411\u0411\u0429                            \u0454  for ANY two cells<br \/>\n          \u0418\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u0458  of the array, there<br \/>\n          is only one path between them. Thus, any cell can be reached<br \/>\n          from any cell, but only by a single unique (see figure 2).<br \/>\n          Computer science jargon refers to such a structure as a<br \/>\n          SPANNING TREE, and it is the creation of this spanning tree<br \/>\n          that is the tricky pary of building a maze.<\/p>\n<p>          \u0419\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u00bb   Finally, the<br \/>\n          \u0454  \u042a\u0414\u0412\u0414\u0412\u0414\u0457  FIGURE 2                  \u0454 of the maze is<br \/>\n          \u0454  \u0413\u0457\u0456\u0456\u0413\u0457\u0456                            \u0454 broken in to<br \/>\n          \u0454  \u0456 \u0456\u0410\u0429\u0456\u0456  One possible spanning     \u0454 provide a start and<br \/>\n          \u0454  \u0413\u0414 \u042a\u0414 \u0456  tree for the array in     \u0454 a finish position.<br \/>\n          \u0454  \u0456\u042a\u0414\u0491 \u042a\u0491  figure 1.                 \u0454 Since there is a<br \/>\n          \u0454  \u0456\u0410\u0414\u0415\u0414\u0456\u0456                            \u0454 unique path between<br \/>\n          \u0454  \u0410\u0414\u0414\u0411\u0414\u0414\u0429                            \u0454 any two cells of the<br \/>\n          \u0418\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u0458 maze, there will be<br \/>\n          a unique path from start to finish. Hence, start and finish<br \/>\n          can be chosen in any convenient manner, say, random<br \/>\n          locations on the opposite sides of the maze (see figure 3).<\/p>\n<p>          \u0419\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u00bb BUILDING THE<br \/>\n          \u0454  \u042a\u0414\u0412\u0414\u0412\u0414\u0457  FIGURE 3                  \u0454 SPANNING TREE<br \/>\n          \u0454  \u0410\u0457\u0456\u0456\u0413\u0457\u0456                            \u0454  starting with a<br \/>\n          \u0454    \u0456\u0410\u0429\u0456\u0456  The spanning tree from    \u0454 fully &#8220;walled-up&#8221;<br \/>\n          \u0454  \u0413\u0414 \u042a\u0414 \u0456  figure 2 with possible    \u0454 array (see figue 1),<br \/>\n          \u0454  \u0456\u042a \u0456 \u042a\u0491  entry and exit points     \u0454 pick a single cell<br \/>\n          \u0454  \u0456\u0410\u0414\u0415\u0414\u0456\u0456  added.                    \u0454 in the array and<br \/>\n          \u0454  \u0410\u0414\u0414\u0411\u0414\u0414                             \u0454 call this cell the<br \/>\n          \u0418\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u041d\u0458 spanning tree. Then<br \/>\n          add cells one at a time to the spanning tree until it fills<br \/>\n          the entire array.<br \/>\n            At any point during this procedure, there will be three<br \/>\n          types of cells in the array:<\/p>\n<p>          o those that are already in the spanning tree.<br \/>\n          o those that are not in the spanning tree, but are<br \/>\n            immediatly adjacent (horizontally or vertically) to some<br \/>\n            cell in the spanning tree (we call there cells FRONTIER<br \/>\n            CELLS)<br \/>\n          o all other cells<\/p>\n<p>            The algorithm follows:<\/p>\n<p>          1. Choose any cell of the array and call it the spanning<br \/>\n          tree. The four cells immediatly adjacent to it (fewer if it<br \/>\n          is on an edge or in a corner) thus become frontier cells.<br \/>\n          2. Randomly choose a frontier cell and connect it to ONE<br \/>\n          cell of the current spanning tree by erasing ONE barrier. If<br \/>\n          it is adjacent to more than one cell of the spanning tree<br \/>\n          (and it could be adjacent to as many as four!), randomly<br \/>\n          choose one of them to connect it to, and erase the<br \/>\n          appropriate barrier.<br \/>\n          3. Check the cells adjacent to the cell just added to the<br \/>\n          spanning tree. Any such cells that are not part of the<br \/>\n          spanning tree and have not previously been marked as<br \/>\n          frontier cells are now marked as frontier cells.<br \/>\n          4. If any frontier cells remain, back to step 2.<br \/>\n          5. Choose start and finish points.<\/p>\n<p>          The article goes on, but I won&#8217;t. This part is enought to<br \/>\n          show how to build a maze.<\/p>\n<div class='watch-action'><div class='watch-position align-right'><div class='action-like'><a class='lbg-style1 like-13942 jlk' href='javascript:void(0)' data-task='like' data-post_id='13942' data-nonce='72e055e984' rel='nofollow'><img class='wti-pixel' src='https:\/\/www.graviton.at\/letterswaplibrary\/wp-content\/plugins\/wti-like-post\/images\/pixel.gif' title='Like' \/><span class='lc-13942 lc'>0<\/span><\/a><\/div><\/div> <div class='status-13942 status align-right'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>HOW TO BUILD A MAZE David Matuszek Department of Computer Science 8 Ayres Hall University of Tennessee&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[27],"class_list":["post-13942","post","type-post","status-publish","format-standard","hentry","category-othernonsense","tag-english","wpcat-7-id"],"_links":{"self":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/13942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/comments?post=13942"}],"version-history":[{"count":1,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/13942\/revisions"}],"predecessor-version":[{"id":13943,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/13942\/revisions\/13943"}],"wp:attachment":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/media?parent=13942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/categories?post=13942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/tags?post=13942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}