textfiles/programming/adventur

100 lines
6.8 KiB
Plaintext
Raw Normal View History

2021-04-15 11:31:59 -07:00
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ<EFBFBD><DCB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ<EFBFBD><DCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD><DFB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ<EFBFBD><DCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD><DBB0> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD><DBB0> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD><DBB0> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD><DBB0> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ<EFBFBD><DCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>߰<EFBFBD><DFB0><EFBFBD>۰<EFBFBD>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܰ<EFBFBD><DCB0><EFBFBD>۰<EFBFBD><DBB0> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۰<EFBFBD><DBB0><EFBFBD>۰<EFBFBD>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>߰<EFBFBD>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD><DFB0><EFBFBD>߰<EFBFBD><DFB0> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD><DFB0><EFBFBD>߰<EFBFBD>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MORE PARSING by Bob Wiber
Hello, before we begin I need to tell you that we will be using the program
listing that was in last months GAZZETTE, the program that was in the library
file has the name of 'ROOMS.BAS'. We will be talking line numbers and you will
probably need a listing handy to make much sense out of this months ramblings,
so I will wait here while you get a listing.
Ok, now we start to take the program apart and follow a command through the
parser and try to figure out how the thing works. Also I'll try to point out a
couple of places that need some special attention. Let's begin with the program
lines between 100 and 900.
This is the area in which the arrays are dimensioned and loaded, and some of the
special values are set into place. Along with this section is the area
beginning with line 9300, this area will expand as we go along adding things to
the bare bones of our adventure game. Right now we only have the data that will
allow us to move around our "world", and at least know the name of the room that
we are in at the time. Later we will expand the 9300+ area to load in other
information that will be needed to run a successful game, but for now I will
leave the explanation for another article (well, I have to have something to
drag this out with).
One point to notice in the loading of the verb and word arrays, we don't do a
FOR-NEXT loop - rather we go until we find "<<END>>". This allows us to edit
the word lists without having to count the number of words in them and change
the length of the loop. The only thing that we need to watch is that the array
is large enough to handle the lists - in our case we can have 150 words in the
verb array and 250 words in the other array with no problem, and with the memory
that is basically standard in most machines today a small array like that is NO
PROBLEM (after all, I write these things on a PC JR with 128K). One other thing
to note is that we have changed the 'name' of the WORDS to TYPE, not really a
large point but a confusing one if you don't catch it right away.
Ok, we have set up the arrays and loaded all of the various background elements
that control our world - now what? At this point we are at line 910 and we find
that the name of the current room is displayed on the screen (which room we are
in is set in line 110 with L=4). Then it tries to decide if EXTRA is true, which
it is not at this time (it's workings will be described later). So, it's off to
line 9000 and the real workhorse around here -- the PARSER (see it even says
so). Here's where I really get into problems and will have to have Aaron check
my work, he wrote it and he is the whiz with strings (and graphics and figuring
out programs and - well, enough) all I know is that I can make it do what I want
by putting in the commands. Anyway, we may all learn something here ---
Line 9005 asks us for our command, and if you don't like the ">" then change the
prompt in the input, but remember - your player has to see it at every move so
the cute "WHAT NOW STUPID?" stuff wears thin real soon (in fact, I have a game
that I haven't finished playing simply because of the prompt lines). Whatever
you choose to do with the prompt let's use the line "GO TO THE NORTH THEN
SOUTH". With that safely entered into the A$ we are off to line 10000. This
little sequence (line numbers 10000-10020) takes all of our input and makes sure
that it is in capital letters, so we can type in our commands in upper, lower or
a combination of the two cases. With that safely out of the way we return to
line 9007 and the main bulk of the parser.
The parser starts off by checking to see if the command that was input is
smaller then three letters long or is a "G", if so a lot of the work can be
eliminated. Other checks that are performed at this time let the computer know
if the command that has been entered is multiple or not, and in the case of our
example it is. This is signified by the use of "THEN" or by using a period,
with this information the computer cuts off the rest of the command line and
assigns it to a holding string (A1$) and sets EXTRA to 1. From this point the
parser checks to see if we are using "G" or"AGAIN" which tells it to repeat the
last command, i.e. the command "GO NORTH. G THEN GET THE CAT. S THEN NW" is
perfectly legal and will be fully complied with - if you haven't made a mistake
(if there is no cat then you won't get it, but you will end up where you told
the computer to put you - so it is important to know what you really want to do
before using the multiple command feature).
At this point the parser just starts to examine the first command and to cut it
into the individual words that make it up. In our example command at this point
we would have set EXTRA, assigned "SOUTH" TO A1$, and would have split the first
command into four individual words. The parser, as with all of the others that
I am aware of, assigns the FIRST word to the verb and lets the others be as they
may with the noun usually being the last word in the command.
Having done all of the above the computer returns to the program lines between
1010 and 1080 with a small detour or two. At this point all we have is four
words and the knowledge that we still have some commands to be worked on. The
following lines really only go through the word strings that the Parser
generated and compare them to the word lists, the verb is done first (lines
9200-9220) and if no verb is present the computer complains that it doesn't
understand the sentence.
[ MORE... To scroll the rest of the article, press Ctrl-Right arrow ]