home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 209
/
209.d81
/
t.animals
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
92 lines
u
A N I M A L S
by M. Poultonavage
If you've ever been curious about
how computers can be used to grow
trees, this program will help you
understand. Not just any tree, mind
you, but binary trees or, as they are
commonly called, b-trees.
You've probably played "Twenty
Questions" where you can always guess
the answer if you use effective
questions that rule out half of the
possible answers each time. That's
what a b-tree does.
This program will allow you to
create a b-tree and save it to disk in
a file called "animals.dat". You
should save the file every time you
play the game.
ANIMALS has a menu of options. The
first time you RUN the program you
will be using the data that is found
at line 9000. You may want to study
these statements to further understand
what is going on, but it isn't really
necessary since you can add to the
list of animals while playing the
game. Since there isn't a file called
"animals.dat" on the LOADSTAR disk,
don't choose 1, "read the file of
animals" unless you enjoy seeing your
drive light blink.
First, choose 5 and 6 from the
menu to see the animals and questions
already in the program.
Then choose 2 to play the game. It
will ask if the animal you are
thinking of has wings. If you say
"yes" by pressing <y> it will say, "is
it a duck?". To add to the data-base,
press <n> for "no" and you'll be asked
for your animal. Enter the name of an
animal that has wings and then enter a
question that will differentiate
between a duck and the animal you
chose. Then choose to play again and
this time your animal will be in the
b-tree at a later "node" than at the
"wings" branch.
This is how you add to the b-tree.
Remember to save your entries before
you quit the game so that next time
you can load the file. If you make a
mistake and say that a snake has short
feathers you can delete an animal by
pressing 3 from the menu.
This game is fun, especially for
youngsters, but it's instructive to
see how a binary tree is constructed.
The program is DIMensioned for up to
999 animals so you can get pretty deep
into the b-tree before running out of
memory. The hard part will be to
decide how to differentiate between
animals that are very similar.
The b-tree strategy is used in all
sorts of human applications,
especially in trouble-shooting, where
it is sometimes called "splitting the
difference".
Once you instinctively understand
the b-tree strategy, you'll become a
much more effective troubleshooter,
and, in a very broad sense, isn't that
what life is all about?
MP