The monkey-banana problem: There many variations to this problem, but the basic premise is that a monkey is in a room with a banana and a chair, and the monkey cannot reach the banana until he moves the chair close to the banana (so as to reach it), then climbs the chair and gets the banana.
(Note : Often times, the chair is replaced with a box or a similar object that the monkey can climb on. Also, a stick may be added to the mix, which the monkey needs to swing at the banana in order to make it drop to the floor.)
I came up with this program to solve a simple monkey-banana problem in AI (no stick). I think it's overly simple, but I would like to know what you think.
on(floor,monkey). on(floor,chair). in(room,monkey). in(room,chair). in(room,banana). at(ceiling,banana). strong(monkey). grasp(monkey). climb(monkey,chair). push(monkey,chair):- strong(monkey). under(banana,chair):- push(monkey,chair). canreach(banana,monkey):- at(floor,banana); at(ceiling,banana), under(banana,chair), climb(monkey,chair). canget(banana,monkey):- canreach(banana,monkey),grasp(monkey).
Should I add location attributes as well? I think that I have hard-coded a lot of things, or maybe having the stick included in the problem would make a better search tree?