home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug117.arc / MAZE.LBR / MAZEBLD.DOC < prev    next >
Text File  |  1979-12-31  |  3KB  |  57 lines

  1.  
  2.                              MAZE BUILDER
  3.                            BY IAN JOHNSTONE
  4.                                13/9/87
  5.  
  6.      Thi≤á prograφ construct≤ ß mazσ froφ widtΦ anΣ heigh⌠ specificat-ì
  7. ion≤á supplieΣá b∙ thσ use≥ anΣ theε offer≤ hiφ thσ choicσá oµá eithe≥ ì
  8. playinτ hi≤ wa∙ ou⌠ oµ thσ maze¼ o≥ watchinτ thσ compute≥ worδ it≤ wa∙ ì
  9. out«á ┴ Microsof⌠ Basiπ versioε (Seσ Beelinσ September¼ 1986⌐ i≤ incl-ì
  10. udeΣ iε thσ librar∙ fo≥ comparisoε oµ time≤ taken«á Thσ Basiπá prograφ ì
  11. take≤á ove≥ 1▓ minute≤ t∩ builΣ ß ful∞ screeε maze¼á whilσ thσ machinσ ì
  12. language program takes less than six seconds.
  13.      Thσá Assembl∙ languagσ sourcσ prograφ i≤ als∩ includeΣá - ╔á hopσ ì
  14. tha⌠á thσ documentatioε i≤ clea≥ enough«á ╔ havσ establisheΣ ß screen-ì
  15. sized buffer at 7000H, each byte being coded as follows:-
  16.           Byte value = 0 - The cell is vacant
  17.           Bit 0 set - Backtracking prohibited
  18.               1     - May move north
  19.               2     -   "   "  east
  20.               3     -   "   "  south
  21.               4     -   "   "  west
  22.      Fo≥ example,iµ thσ cel∞ representeΣ b∙ thσ bytσ a⌠ locatioε 7350╚ ì
  23. i≤á t∩ bσ giveε aε exi⌠ t∩ thσ nortΦ (wσ neeΣ no⌠ kno≈á whethe≥á therσ ì
  24. are other exits), this can be done by:-
  25.           LD A,(7350H)
  26.           OR 2
  27.           LD (7350H),A
  28.      Thσá graphiπ fo≥ ß cel∞ witΦ ß nortΦ exi⌠ woulΣ bσ ß bo° witΦ thσ ì
  29. to≡á opeε (seσ thσ firs⌠ linσ oµ MAZDAT┴ iε thσ sourcσ codσ wherσá thσ ì
  30. PC╟ areß fo≥ CHR$(129⌐ (o≥ CHR$(128+1⌐ i≤ giveε jus⌠ sucΦ ßá graphic)¼ ì
  31. then all we  need to do is:-
  32.           LD   HL,7350H
  33.           LD   A,(HL)   ;Get the cell code
  34.           RRA           ;Divide by two
  35.           AND  0FH
  36.           OR   128      ;A will now be 129
  37.           LD   DE,8000H ;Offset to equivalent location on screen
  38.           ADD  HL,DE
  39.           LD   (HL),A   ;This will display CHR$(129) at 0F350H
  40.      Iε othe≥ area≤ North¼á East¼á SoutΦ anΣ Wes⌠ (notσ thσ order⌐ arσ ì
  41. giveεá thσ value≤ oµ 1¼á 2¼á │ anΣ 4«á Thi≤ enable≤ ß righ⌠ turε t∩ bσ ì
  42. madσ b∙ incrementinτ thσ directioε anΣ vicσ versß fo≥ ß lef⌠ turn¼á a≤ ì
  43. long as the values are kept within the range 1 to 4.
  44.      Wheεá movinτ rounΣ thσ maze¼á yo⌡ caε onl∙ ente≥ cell≤ no⌠á prev-ì
  45. iousl∙á entereΣ,áexcep⌠á wheε backtrackinτ anΣ onl∙ theεá wheεá i⌠á i≤ ì
  46. allowed«á Backtrackinτ i≤ donσ t∩ ge⌠ ou⌠ oµ blinΣ alley≤ anΣ ma∙ onl∙ ì
  47. bσ donσ oncσ iε eacΦ cell« Unles≤ yo⌡ haΣ thi≤ rule¼ yo⌡ coulΣ bσ lef⌠ ì
  48. wandering through the maze for all eternity.
  49.      Thσá auto-escapσá routinσ wa≤ thσ resul⌠ oµá thσá thought¼á whicΦ ì
  50. proved wrong, that this might be the beginnings of an experience in AI
  51. Thσá rulσá fo≥ escapinτ froφ ß mazσ i≤ t∩ pu⌠ onσ hanΣ oε ßá wal∞á anΣ ì
  52. neve≥ le⌠ i⌠ leavσ tha⌠ wal∞ unti∞ yo⌡ arσ ou⌠ oµ thσ maze«á Thσ righ⌠ ì
  53. hand rule is applied here viz.,
  54.           Take a stem
  55.           If you strike a wall, turn leftè          If you don't strike a wall, turn right
  56.           Never go straight ahead
  57.