% Picky eater shellOAVbc rules. % % This is the better version. % % (This code was a solution to EE 4785 1995 HW 5, Problem 2.) % % In this version two classes are used: one for % foods, `foodType', the other for animals, `animal'. % % There is one disadvantage over the simple version, which is a % shortcoming of the shell: in questions presented to the user objects % are identified by their object name (e.g., foodType3) rather than % their name (e.g., bakedZiti). This is easy to fix, in fact it was a % homework question in a previous semester. % % (The solution in file roPE.pro does not have a class for food and % animals.) Because foods and animals are instances their object % names will be of the form foodType1, foodType2, animal1, animal2, % etc. Therefore the predicate Food:.whenAlive=Animal will not % work. Instead the following would have to be used to find out what % `Food' was made from: % thereExist(FO:.name=Food,FO:.whenAlive=Animal). See rules `nfr' and % `nar'. % % Difference between class `food' and `foodType'. % % There will be an instance of `food' for each food the user is % considering (i.e., on the menu). There will be an instance of % `foodType' for every food the expert system knows about. % Picky eater shellOAVbc rules. % % To start issue goal: % % ?-start. % Start shell by finding truth value of eatSomething. % start:-rootGoal(eatSomething). % Rule to determine if food F is acceptable. % rule1:if F:.name=FoodName % Get name of menu item. and getFoodObjName(FoodName,FoodObj) % Make food object, if necessary. and FoodObj:.whenAlive=AnimalName % Find animal used. and getAnimalObjName(AnimalName,AnObj) % Make animal object, if necessary. and L=AnObj:.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(menu,person) % Get list of people and. and % (Below) test each for acceptability. forSome(Food:.isa=menu,true,Food:.wouldEat) then eatSomething. % The proposition. nfr:if % (Below) succeed if food is % already in system. thereExist(ObjName:.isa=foodType,ObjName:.name=FoodName) or % Otherwise... new(foodType,ObjName) % ...create a new instance. and % (Below) assign name. conclude(ObjName:.name,FoodName,user) and sOut<