:-[-stdStuff]. % Decision tree program. Implements a simple decision tree expert % system. node facts store questions: % % node(NodeName,QuestionText,AnswerList) % % The AnswerList component describes the child node associated with % each answer: a(Answer,ChildNode) % % To run, enter query: tree(root). % The root node is the root of the tree. % node(root,'How many legs does it have',[a('0',qSwim),a('2',qFeath),a('4',qHoof)]). node(qSwim,'Can it swim?',[a('Yes',aFish),a('No',aSnake)]). node(qFeath,'Does it have feathers?',[a('Yes',aBird),a('No',aHuman)]). node(qHoof,'Does it have hoofs?',[a('Yes',aHorse),a('No',qAtt)]). node(qAtt,'Does it have an attitude problem?',[a('Yes',aCat),a('No',aDog)]). node(aCat,'The animal is a cat.',[]). node(aHorse,'The animal is a horse.',[]). node(aHuman,'The animal is a human.',[]). node(aBird,'The animal is a bird.',[]). node(aFish,'The animal is a fish.',[]). node(aSnake,'The animal is a snake.',[]). node(aDog,'The animal is a dog.',[]). start:-tree(root). tree(NodeName):- node(NodeName,Q,AnsList), sOut< 0,AnsNum =< HighestNum,nl. getAns([a(Choice,Node)|More],AnsNode,PrevItem):- Item is PrevItem+1,sOut<