Finding a route through a maze using Prolog
Scenario 1 Finding a route through a maze using Prolog An artificially intelligent robot is asked to navigate a maze as shown in Figure 1. It is placed at a certain position (the starting position – a room) in the maze and is asked to try to reach another position (the goal position – a room). Positions are identified by (X, Y) coordinates. a b c d f e Figure 1 The figure 1 represents a maze in which we are asked "is there a route from point X to point Y?" Assume, that the following knowledge base (i.e., facts) describes the paths through the maze. link(a,b). link(b,c). link(c,d). link(f,c). link(b,e). link(d,e). link(e,f). Even at this point we could put these in a Prolog program and start asking simple questions (by writing queries in the console) such as “Is there a link between points b and a?”. Task 1 Write a predicate that defines a route between any two adjacent points (X and Y for example) based on the fact that there is a link between them and a recursive predicate that covers the more general case of a route between any two non-adjacent points (X and Z for example) by establishing for a fact that there is a link between X and a third point in the maze (say Y) and a route between Y and Z. Hand in: a. Inference networks for the rules. b. A Prolog program called maze_one.pl. c. A detailed description of the operation of the predicates. Task 2 Add two special rooms – one connected to “a” and called “Entry” and another one connected to “f” and called “Exit”. Add a set of facts to reflect the two new rooms. Using the predicates from task 1, write a predicate that finds all possible routes between the Entry and the Exit and creates a list of the visited rooms. Write another predicate that displays the list in the interactive console at the end of every iteration, or in other words every time the Exit is reached. Write a test plan that shows your anticipated results and the actual results. Evaluate this solution and identify any...
10 years ago
Purchase the answer to view it
- finding_a_route_through_a_maze_using_prolog.docx