Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

"20q" in perl?

by schweini (Friar)
on Oct 05, 2005 at 20:31 UTC ( [id://497735] : perlquestion . print w/replies, xml ) Need Help??

schweini has asked for the wisdom of the Perl Monks concerning the following question:

most of you may be familiar with the '20q' game that is offered on, which seems to be a rather generic neuralnet based expert system (not sure about the 'expert system' part). i seem to remember that it was originally programmed in perl, yet google doesn't help too much looking for it.
Does anybody know where i could find the source of something similar, preferrably with a big knowledgebase? AFAIK, the algorithms used are extremly generic, and could be used for a lot of fun stuff, but i forgot all everything my AI classes taught me, so i couldn't be able to program something like that from scratch.


Replies are listed 'Best First'.
Re: "20q" in perl?
by SamCG (Hermit) on Oct 05, 2005 at 21:53 UTC
    this node might help, though it doesn't have a knowledge base (you'd need to code that in yourself). Look at merlyn's response as well, it a nice alternative...
Re: "20q" in perl?
by spiritway (Vicar) on Oct 06, 2005 at 05:27 UTC

    It's a glorified binary search. With 20 questions, you get 2**20 possibilities, or about a million.

Re: "20q" in perl?
by eric256 (Parson) on Oct 06, 2005 at 03:17 UTC

    I can't find any confirmation but I'm pretty cure is NOT a nueral net. There is no need for it to be. Basicaly it breaks down to this. You have a set of objects and a set of questions. For each object you have 1 or more questions (more = better) that you know the answers to. Start with a random question (hopefully one that divides the rest of your items in half). Then continue to ask questions that divide the rest of your items in half (half say yes and half say no). You should reach the bottum of your tree and be left with the item that the user is guessing. There are some finer points since some items wont have answers to all questions. Obviously though the more questions and items/answers you have the smarter your system seems. I've programmed one of these in the past and they are quite fun and seem quite intellegent.

    Eric Hodges
      i was just guessing "neural" because i just assumed that 20q does handle some kind of 'link strength' between questions and answers so that a question that gets the same answer 20 times makes that answer more 'important' than some random answer given by a lost user. and IIRC, that was the basic mechanism of neural networks - that repeated 'stimuli' reinforce a 'link' - although i might be completly wrong (i still think it would make sense, though: wikipedia works because they assume that most users will actually do the 'good' thing, and the minority that do nonsense just dissapear under the flood of good stimuli/edits)

      i somehow assumed q20 was open source or something, but i guess i was wrong. :(

      one possible application i saw was for medicine, because looking over my gf's shoulder while she was studying, i noticed that a lot of diagnoses seem to be kind of fuzzy, and have a lot of interconnections with other symptons. (e.g. high blood pressure with diabetes is different from high blood pressure with only smoking), so i thought an 'intelligent' q20 thing would at least be a help for doctors.
      on the other hand, i once heard that medical expert systems failed because too many diagnoses are actually made intuitivly/subconciously, due to the sheer amount of possible sympton-diagnose relationships.
      ah well. would still be interesting, i guess - anybody know of some machine-readable symptom -> diagnosis graph?
Re: "20q" in perl?
by YuckFoo (Abbot) on Oct 06, 2005 at 22:22 UTC
Re: "20q" in perl?
by schweini (Friar) on Oct 07, 2005 at 00:33 UTC