home *** CD-ROM | disk | FTP | other *** search
-
- ZERO PAGE: THE LOADSTAR 128 DICTIONARY
-
- by Fender Tucker and Jeff Jones
-
-
- I remember the first computer word game I came across. It was called
- WORDSMITH and it was on one of the very first LOADSTARs. The rules were
- simple: the computer provided a four-letter word and you were to change one
- of the letters in the word to make another four-letter word. Then it was
- the computer's turn to do the same. As soon as one of you couldn't come up
- with a word that hadn't been used yet, the game was over.
-
- The program came with 26 SEQ files full of words for the computer to
- use -- one for each letter of the alphabet. The computer had to search
- through these files every time a word was entered so you can imagine what a
- slow game it was. The only reason it was reasonably fast was that the word
- lists weren't very big. Consequently, we haven't published any more
- programs that required the computer to recognize if an entered sequence of
- letters was actually a word.
-
- Until now. Recently I was given a dictionary disk by the Apple
- department here at Softdisk. I had them convert it to IBM ASCII and from
- there I used Big Blue Reader to get it in Commodore PETASCII format. It was
- huge -- the five-letter word list was over 300 blocks long! It had a
- carriage return after each word and contained every five-letter sequence
- ever uttered by William Buckley. I needed to do something to get this into
- a format we could use in our programs.
-
- First I wrote a little program that displayed each word on the screen
- one at a time and asked me if I wanted it saved in another file. I spent a
- very boring few hours going through the 10,000+ words deciding which ones
- are "normal" enough and which ones are only known to crossword fans.
- (Luckily there was a "Get Smart" marathon on Nickelodeon at the time.) I
- tried to be fairly liberal with my decisions (for instance, I allowed
- "abaca" because I figured it meant two abacuses). I undoubtedly made
- mistakes and bypassed a few words that should be in the list, and allowed a
- few that shouldn't. You try looking at 10,000 words, one at a time, in one
- sitting. A few plurals got past me, but in general, there are no plurals in
- the list.
-
- So now I had a 63-block long list of five-letter words attached to each
- other with no carriage returns. Just one word after another. There are
- 3403 words in the list. Then I asked Jeff Jones to come up with an ML
- routine that, when given a five-letter word, would zip through the list and
- let me know if it's in it. It had to be fast. He surprised me by making
- his ML even more powerful by allowing ? wildcards. This means that you can
- pass the ML something like "ab?ca" and it will find all words that fit that
- pattern, one at a time.
-
- It's fast. Play BLOTTO and you'll see that the computer takes less
- than a second to determine if a word is in the dictionary. BLOTTO didn't
- require the wildcard feature, but WORDSMITH would.
-
- I imagine there are hundreds of nifty word games waiting to be written
- now that there's a way to quickly (and painlessly) determine if a
- five-letter sequence is really a word. I'm hoping that the excellent 128
- programmers out there will be inspired to write some and send them to
- LOADSTAR 128 for publication and big bucks.
-
- Here is another bonus: I also went through the four-letter list I
- received from the Apple guys and Jeff added it to the dictionary. So
- four-letter word games are possible -- or games that can use both four- and
- five-letter words. The same ML will handle either word length.
-
- Everything you need is found in the 96-block file called "dictionary
- 9400". It resides in BANK 1 at page 148 so you need to use these lines to
- load it into place:
-
- 10 poke58,148:clr:dv=peek(186):ifdv<8thendv=8
- 20 bload"dictionary 9400",u(dv),b1,p37888
-
- where dv is the current drive. Line 10 protects the dictionary from being
- overwritten by BASIC variables and sets the drive number (dv) to the current
- drive. Line 20 BLOADs the dictionary into place in BANK 1.
-
- Then you write your program. When you come to the place where you want
- to check if a sequence is really a word, use this set of commands:
-
- 2000 w$="board":hb=int(pointer(w$)/256):lb=int(pointer(w$)-hb*256)
- 2010 bank1:sys37888,lb,hb:bank15
-
- If the word "board" is really a word, w$ will equal "board" when the program
- comes back to BASIC. If it's not in the dictionary, w$ will equal a null
- string, (""). You may use any variable name in place of w$. Just use the
- same string variable throughout the commands.
-
- If w$ is a four-letter word, the program will even more quickly check
- just the four-letter word dictionary.
-
- To use a wildcard, just use a question mark (?) in w$. If w$="cr??e"
- then after line 2010 above, w$ will equal "crane". To find the next word
- that fits the pattern use this command:
-
- 2020 bank1:sys37891:bank15
-
- and w$ will equal "crate". To find all of the words that fit the pattern,
- use a loop like this:
-
- 2020 i = 1 : bank1
- 2030 sys37891
- 2040 if w$ = "" then 2080
- 2050 wd$(i) = w$
- 2060 i = i + 1
- 2070 goto 2030
- 2080 bank15:program continues with all matching words in the array wd$(x)
-
- Make sure to DIMension wd$(x) large enough to hold all of the matches you
- anticipate. Since perverse users will try to enter "?????" if you allow
- them to use wildcards, you probably will need to TRAP the program to take
- care of the "bad subscript" error you'll get if you don't DIMension to at
- least 3403. Obviously, "?????" would find all 3403 five-letter words.
-
- That's about all there is to know about using "dictionary 9400". We
- will probably come up with an improved dictionary that has two- and
- three-letter words, as well as some new ML tools for using the lists. For
- instance, if you want to have the computer choose a word from its dictionary
- at random, you would just do a SYS. In the meantime, here's a short BASIC
- routine that will pick a word at random from the five-letter list:
-
- 3000 v$ = "" : bank1
- 3010 r = int(rnd(1) * 3403)
- 3020 for i = 0 to 4
- 3030 v$ = v$ + chr$(peek(45122 + r * 5 + i))
- 3040 next : bank15
-
- The word will be found in v$. For four-letter words, substitute:
-
- 3010 r = int(rnd(1) * 1679)
- 3020 for i = 0 to 3
- 3030 v$ = v$ + chr$(peek(38400 + r * 4 + i))
-
- From the above numbers you can tell that there are 1679 words in the
- four-letter list and that they begin in memory at 38400 in BANK 1.
-
- I found that returning the program back to the default bank, BANK 15,
- is a good idea, since I use some ROM routines in BANK 15. I'm sure that
- programmers who are more conversant with BANKing on the 128 than I am will
- know what to do.
-
- Use the dictionary as you wish in your programs, but please mention
- that you got it from LOADSTAR 128 if you upload or sell your program. Of
- course the most profitable thing to do with your programs is to send them to
- LOADSTAR 128.
-
- FT
-
- **** RETURN - Menu ****
-