Supposing, we want to build a logical agent to bag groceries in the manner of a grocery-store checkout clerk.
We are not interested in optimal packing, but we want the robot to follow some of the fundamentals of grocery bagging:
1) big bottles of soda go in the bottom, with not too many in one bag.
2) ice cream is protected with freezer bags.
3) little things are stuffed here and there when everything is in place.
Design a knowledge base (KB) agent, Bagger, and implement Bagger in Python, that follows the five steps as defined by the following procedure description:
1. Check what the customer has selected, looking over the groceries to see if something is missing, with a view towards making suggestions to the customer.
2. Bag the large items, with special attention to putting in big bottles first.
3. Bag the medium items, taking care to put frozen things in freezer bags first.
4. Bag the small items, putting them wherever there is room.
5. Whenever necessary, Bagger commands the robot to start a new bag.
The database must contain information about the items in each bag, the items yet to be bagged, and the current step.
Hints on how this data base could be established:
The KB agent must have rules to access information about the size and other properties of various items:
Item Container Type Size Frozen?
Bread Plastic Bag Medium No
Glop Jar small No
Granola Cardboard Box Large No
Ice Cream Cardboard Carton Medium Yes
Potato Chips Plastic Bag Medium NO
In the check order step, there are potato chips (dry and salty), Bagger could add a soft drink.
Then a rule must be added to get out of check_order and go on to Bag_large_items (since this must be done first). Adopt a suitable conflict_resolution strategy (ad-hoc). Use a conflict limiting strategy to reduce the likelihood of conflict by separating rules into groups, only some of which are active at any time. Have a procedure that activates and deactivates groups. Groups can be ordered according to preference.
Have Bag_medium_items step as well as a Bag_Small_Items step.
Make sure the rules are ordered properly and the conflict resolution strategy works, if more than one rule gets triggered.
Make sure you have the rule to terminate action when done
Your program should terminate with all items bagged.