Category : Miscellaneous Language Source Code
Archive   : KINOOP.ZIP
Filename : ANIMAL.KIN

 
Output of file : ANIMAL.KIN contained in archive : KINOOP.ZIP
"KIN" Version 1.0, Copyright (c) 1992, RPS, All Rights Reserved.
Classic animal guessing game.
Produces a binary tree based upon accumulated questions and answers.

kin r(0); // turn off result displays
kin loadclass(endclass); // define classes
class treenode
prop parent // pointer to parent

class question
super treenode // parent
prop myquestion // question
prop yesbranch // pointer to yes answer branch
prop nobranch // pointer to no answer branch
method setno // set the no branch to fcn parm
kin self~nobranch = parm(1);

method setyes // set the yes branch to fcn parm
kin self~yesbranch = parm(1);

method ask // ask question, branch on result
kin _c=gets(self~myquestion),
if (not strcmp(_c,"y"),
(b=self~yesbranch,b~ask(0,self~yesbranch)),
0),
if (not strcmp(_c,"n"),
(b=self~nobranch,b~ask(1,self~nobranch)),
0);

class animal
super treenode // parent
prop name // animal
method ask // ask question about animal
kin _c=gets(strcat(strcat("Is it a ",self~name),"? ")),
if (not strcmp(_c,"y"), $="I got it", // all done
{ // else, add new question and animal nodes
_c=gets("I don't know this one. What kind of animal were you thinking of? "),
$=splice(__,"Please type a question that distinguishes between a ",
_c," and a ",self~name),
_d=gets("> "),
$=splice(__,"Remind me about a ",_c,". ",_d),
_p=strcmp("y",gets("(y|n)? ")),
f(0.0), // try a -9.0lf
if (_p,(_y=parm(2),_n=strcat('a1.',text(count(a1)+1))),
(_n=parm(2),_y=strcat('a1.',text(count(a1)+1)))),
splice(__,self~parent,',',_d,',',_y,',',_n),
question:q1=+__, // new question object
splice(__,'q1.',newq=count(q1),',',_c),
animal:a1=+__, // new animal object
if (parm(1),
(b=self~parent,b~setno(strcat('q1.',text(newq)))),
(b=self~parent,b~setyes(strcat('q1.',text(newq))))),
self~parent=strcat('q1.',text(newq)),
f(9.0)
}
);
endclass

kin animal:a1=$; // load some animal objects
q1.3,fish
q1.4,penquin
q1.4,dolphin
q1.2,robin
q1.2,lion

kin question:q1=$; // load some question objects
,Does it swim? ,q1.3,q1.2
q1.1,Is it a bird? ,a1.4,a1.5
q1.1,Does it have gills? ,a1.1,q1.4
q1.3,Does it have feathers? ,a1.1,a1.2

kin r(2); // turn on result display
kin while (1,( // MAIN PROGRAM LOOP
_c=gets("Would you like to think of another animal? "),
if (not strcmp(_c,"n"),break(),(bv='q1.1',bv~ask()))
));

kin $=question:q1; // print resulting question objects

kin $=animal:a1; // print resulting animal objects


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : KINOOP.ZIP
Filename : ANIMAL.KIN

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/