% Picky eater shellOAVbc rules. % % This is the simple version: % % Data about food and animals kept in static objects, new foods and animals % cannot be added by the user. % % Names are used as object identifiers. (It's better to store a name in an % attribute.) % % A better version is in file roPE2.pro. % % To start issue goal start: (I thought of this before Microsoft. :-) ) % % ?- start. % Start shell by finding truth value of eatSomething. % start:-rootGoal(eatSomething). % Rule to determine if food F is acceptable. % rule1:if F:.name=N % Get name of food. and N:.whenAlive=Animal % Find animal used. and L=Animal:.numLegs % Find number of legs. and call(number(L)) and L>1 and L<5 % Test number. then F:.wouldEat. % The proposition. rule2:if doList(food,person) % Get list of foods and. and % (Below) test each for acceptability. forSome(Food:.isa=food,true,Food:.wouldEat) then eatSomething. % The proposition. % Command which asks about first instance in Class. % newInstRule1:if Class:.firstQuest=Q % Get first question. and askAndCheck(Q,Parent,yesNo,Ans) % Ask. and % (Below) If yes, create instance. ( Ans=true and makeNew1(Class,Parent) or Ans=false ) then doList(Class,Parent). % The command. % Command which creates instance and asks about more instances. % newInstRule2:if new(Class,InstName) % Create instance. and InstName:.name=T % Find name. and Class:.moreQuest=Q % Retreive "more" question. and askAndCheck(Q,Parent,yesNo,Ans) % Ask. and % If yes, make recursive call. ( Ans=true and makeNew1(Class,Parent) or Ans=false ) then makeNew1(Class,Parent). % The command. % Data and properties for food class. % data(food,firstQuest,"Is there a menu item?",init). data(food,moreQuest,"Are there any other menu items?",init). props(food,name, "This menu item will be refered to as *. What food is it?",isString). % Single instance objects. % data(steak,whenAlive,cow,init). data(escargot,whenAlive,snail,init). data(chicken,whenAlive,chicken,init). data(cow,numLegs,4,init). data(snake,numLegs,0,init). data(snail,numLegs,1,init). data(chicken,numLegs,2,init). % Items to announce when proven. % aGoalList([food:.wouldEat,eatSomething]).