When we have reached to the state ‘ has>’, this indicates ‘ has banana’. Here we pass a state, so this will perform move predicate from one state to another using different actions, then perform canget() on state 2. Monkey can move from one place to another using walk or move clauses.Īnother predicate will be canget(). ![]() The push or drag operation moves the block from one place to another. on top state), by performing the action climb. has not state), then using the grasp action, it will change from has not state to have state.įrom the floor, it can move to the top of the block (i.e. When the block is at the middle, and monkey is on top of the block, and monkey does not have the banana (i.e. We have some predicates that will move from one state to another state, by performing action. We will create some predicates as follows − Now, let us see how we can solve this using Prolog. When the monkey is on the block, and block is at the center, then the monkey can get the bananas. So the vertical position of the monkey will be changed. If monkey and the block both are on the floor, and block is at the center, then the monkey can climb up on the block. If the block position is not at the center, then monkey can drag it to the center. From the above image, we can see that both the monkey and the block are on the floor. Monkey can reach the block, if both of them are at the same level. ![]() Below are few observations in this case − So if the monkey is clever enough, he can come to the block, drag the block to the center, climb on it, and get the banana. The monkey wants the banana, but cannot reach it. ![]() There is a block (or chair) present in the room near the window. Problem StatementĪ hungry monkey is in a room, and he is near the door.īananas have been hung from the center of the ceiling of the room. % write( "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n"),įind_children(NodeList,TopList,HeuristicVal):-įind_children(NodeList,TopList,HeuristicVal):-!.In this prolog example, we will see one very interesting and famous problem, The Monkey and Banana Problem. % retract(curr_db_list(NodeList,TopList,HeuristicVal)),įind_children(NodeList,TopList,HeuristicVal),īest_child(BestNodeList,BestTopList,BestHVal),Īssert(curr_db_list(BestNodeList,BestTopList,BestHVal)), Move_block(integer,nodetype_list,top_list)Ĭopy_on_top_to_db(nodetype_list,top_list)Īssert(curr_db_list(NodeList,TopList,HeuristicVal)),Ĭurr_db_list(NodeList,TopList,HeuristicVal),
0 Comments
Leave a Reply. |