Prolog block world problem5/18/2023 ![]() 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. Moves to transform state x to a goal stateĪn algorithm is available for getting an approximation of h(x) which is an unknown value.In this prolog example, we will see one very interesting and famous problem, The Monkey and Banana Problem. H(x) is the number of non-blank tiles not in Keeping that in mind, we define a cost function for the 8-puzzle algorithm as below: c(x) = f(x) + h(x) whereį(x) is the length of the path from root to x We assume that moving one tile in any direction will have a 1 unit cost. The ideal Cost function for an 8-puzzle Algorithm : H(X) = cost of reaching an answer node from X. The cost function is defined as C(X) = g(X) + h(X) where The next E-node is the one with the least cost. The cost function is useful for determining the next E-node. All children of a dead node have already been expanded.Įach node X in the search tree is associated with a cost. Dead node is a generated node that is not to be expanded or explored any further. In other words, an E-node is a node currently being expanded.ģ. E-node is a live node whose children are currently being explored. Live node is a node that has been generated but whose children have not yet been generated.Ģ. There are basically three types of nodes involved in Branch and Boundġ. It is similar to the backtracking technique but uses a BFS-like search. The search for an answer node can often be speeded by using an “intelligent” ranking function, also called an approximate cost function to avoid searching in sub-trees that do not contain an answer node. But no matter what the initial state is, the algorithm attempts the same sequence of moves like DFS. This always finds a goal state nearest to the root. We can perform a Breadth-first search on the state space tree. ISRO CS Syllabus for Scientist/Engineer Exam. ![]()
0 Comments
Leave a Reply. |