home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 19 / q19.d81 / t.dictionary < prev    next >
Text File  |  2022-08-28  |  7KB  |  149 lines

  1.  
  2.                     ZERO PAGE: THE LOADSTAR 128 DICTIONARY
  3.  
  4.                         by Fender Tucker and Jeff Jones
  5.  
  6.  
  7.      I remember the first computer word game I came across.  It was called
  8. WORDSMITH and it was on one of the very first LOADSTARs.  The rules were
  9. simple: the computer provided a four-letter word and you were to change one
  10. of the letters in the word to make another four-letter word.  Then it was
  11. the computer's turn to do the same.  As soon as one of you couldn't come up
  12. with a word that hadn't been used yet, the game was over.
  13.  
  14.      The program came with 26 SEQ files full of words for the computer to
  15. use -- one for each letter of the alphabet.  The computer had to search
  16. through these files every time a word was entered so you can imagine what a
  17. slow game it was.  The only reason it was reasonably fast was that the word
  18. lists weren't very big.  Consequently, we haven't published any more
  19. programs that required the computer to recognize if an entered sequence of
  20. letters was actually a word.
  21.  
  22.      Until now.  Recently I was given a dictionary disk by the Apple
  23. department here at Softdisk.  I had them convert it to IBM ASCII and from
  24. there I used Big Blue Reader to get it in Commodore PETASCII format.  It was
  25. huge -- the five-letter word list was over 300 blocks long!  It had a
  26. carriage return after each word and contained every five-letter sequence
  27. ever uttered by William Buckley.  I needed to do something to get this into
  28. a format we could use in our programs.
  29.  
  30.      First I wrote a little program that displayed each word on the screen
  31. one at a time and asked me if I wanted it saved in another file.  I spent a
  32. very boring few hours going through the 10,000+ words deciding which ones
  33. are "normal" enough and which ones are only known to crossword fans. 
  34. (Luckily there was a "Get Smart" marathon on Nickelodeon at the time.)  I
  35. tried to be fairly liberal with my decisions (for instance, I allowed
  36. "abaca" because I figured it meant two abacuses).  I undoubtedly made
  37. mistakes and bypassed a few words that should be in the list, and allowed a
  38. few that shouldn't.  You try looking at 10,000 words, one at a time, in one
  39. sitting.  A few plurals got past me, but in general, there are no plurals in
  40. the list.
  41.  
  42.      So now I had a 63-block long list of five-letter words attached to each
  43. other with no carriage returns.  Just one word after another.  There are
  44. 3403 words in the list.  Then I asked Jeff Jones to come up with an ML
  45. routine that, when given a five-letter word, would zip through the list and
  46. let me know if it's in it.  It had to be fast.  He surprised me by making
  47. his ML even more powerful by allowing ? wildcards.  This means that you can
  48. pass the ML something like "ab?ca" and it will find all words that fit that
  49. pattern, one at a time.
  50.  
  51.      It's fast.  Play BLOTTO and you'll see that the computer takes less
  52. than a second to determine if a word is in the dictionary.  BLOTTO didn't
  53. require the wildcard feature, but WORDSMITH would.
  54.  
  55.      I imagine there are hundreds of nifty word games waiting to be written
  56. now that there's a way to quickly (and painlessly) determine if a
  57. five-letter sequence is really a word.  I'm hoping that the excellent 128
  58. programmers out there will be inspired to write some and send them to
  59. LOADSTAR 128 for publication and big bucks.
  60.  
  61.      Here is another bonus: I also went through the four-letter list I
  62. received from the Apple guys and Jeff added it to the dictionary.  So
  63. four-letter word games are possible -- or games that can use both four- and
  64. five-letter words.  The same ML will handle either word length.
  65.  
  66.      Everything you need is found in the 96-block file called "dictionary
  67. 9400".  It resides in BANK 1 at page 148 so you need to use these lines to
  68. load it into place:
  69.  
  70.  10 poke58,148:clr:dv=peek(186):ifdv<8thendv=8
  71.  20 bload"dictionary 9400",u(dv),b1,p37888
  72.  
  73. where dv is the current drive.  Line 10 protects the dictionary from being
  74. overwritten by BASIC variables and sets the drive number (dv) to the current
  75. drive.  Line 20 BLOADs the dictionary into place in BANK 1.
  76.  
  77.      Then you write your program.  When you come to the place where you want
  78. to check if a sequence is really a word, use this set of commands:
  79.  
  80.  2000 w$="board":hb=int(pointer(w$)/256):lb=int(pointer(w$)-hb*256)
  81.  2010 bank1:sys37888,lb,hb:bank15
  82.  
  83. If the word "board" is really a word, w$ will equal "board" when the program
  84. comes back to BASIC.  If it's not in the dictionary, w$ will equal a null
  85. string, ("").  You may use any variable name in place of w$.  Just use the
  86. same string variable throughout the commands.
  87.  
  88.      If w$ is a four-letter word, the program will even more quickly check
  89. just the four-letter word dictionary.
  90.  
  91.      To use a wildcard, just use a question mark (?) in w$.  If w$="cr??e"
  92. then after line 2010 above, w$ will equal "crane".  To find the next word
  93. that fits the pattern use this command:
  94.  
  95.  2020 bank1:sys37891:bank15
  96.  
  97. and w$ will equal "crate".  To find all of the words that fit the pattern,
  98. use a loop like this:
  99.  
  100.  2020 i = 1 : bank1
  101.  2030 sys37891
  102.  2040 if w$ = "" then 2080
  103.  2050 wd$(i) = w$
  104.  2060 i = i + 1
  105.  2070 goto 2030
  106.  2080 bank15:program continues with all matching words in the array wd$(x)
  107.  
  108. Make sure to DIMension wd$(x) large enough to hold all of the matches you
  109. anticipate.  Since perverse users will try to enter "?????" if you allow
  110. them to use wildcards, you probably will need to TRAP the program to take
  111. care of the "bad subscript" error you'll get if you don't DIMension to at
  112. least 3403.  Obviously, "?????" would find all 3403 five-letter words.
  113.  
  114.      That's about all there is to know about using "dictionary 9400".  We
  115. will probably come up with an improved dictionary that has two- and
  116. three-letter words, as well as some new ML tools for using the lists.  For
  117. instance, if you want to have the computer choose a word from its dictionary
  118. at random, you would just do a SYS.  In the meantime, here's a short BASIC
  119. routine that will pick a word at random from the five-letter list:
  120.  
  121.  3000 v$ = "" : bank1
  122.  3010 r = int(rnd(1) * 3403)
  123.  3020 for i = 0 to 4
  124.  3030 v$ = v$ + chr$(peek(45122 + r * 5 + i))
  125.  3040 next : bank15
  126.  
  127. The word will be found in v$.  For four-letter words, substitute:
  128.  
  129.  3010 r = int(rnd(1) * 1679)
  130.  3020 for i = 0 to 3
  131.  3030 v$ = v$ + chr$(peek(38400 + r * 4 + i))
  132.  
  133. From the above numbers you can tell that there are 1679 words in the
  134. four-letter list and that they begin in memory at 38400 in BANK 1.
  135.  
  136.      I found that returning the program back to the default bank, BANK 15,
  137. is a good idea, since I use some ROM routines in BANK 15.  I'm sure that
  138. programmers who are more conversant with BANKing on the 128 than I am will
  139. know what to do.
  140.  
  141.      Use the dictionary as you wish in your programs, but please mention
  142. that you got it from LOADSTAR 128 if you upload or sell your program.  Of
  143. course the most profitable thing to do with your programs is to send them to
  144. LOADSTAR 128.
  145.  
  146. FT
  147.  
  148.                            **** RETURN - Menu ****                          
  149.