Highlights
Part 1. Finding a route
(a) Define a program named route(Origin, Destination, Route), that when given a value for the Origin you are searching from and a value for the Destination you want to reach, the program returns the Route as a Prolog list. Such a list contains the intermediate points that one needs to go through from Origin to Destination. Also, there maybe more than one route. For example, if you ask the query?- route(‘Outside’, ‘Living Room’, Route). you should get the following answers with your program:
Route = [‘Outside’, ‘Porch 1’, ‘Kitchen’, ‘Living Room’] ;
Route = [‘Outside’, ‘Porch 2’, ‘Living Room’] ; false.
You could implement the route/3 program above using different strategies to search for a route (e.g. breadth first or depth first) – which strategy to use is up to you.
Test your program using Fig. 1 by asking different queries and see whether your work produces the right outcomes.
(b) Use the route/3 program you defined in Part 1(a) to implement a new program shortest route(Origin, Destination, Route) to find the shortest Route between Origin and Destination; shortest means minimising the number of place you visit to arrive at the ‘Destination’. If you consider, for example, going ‘Outside’ from the ‘Living Room’, then you will see that there are two routes (one via ‘Porch 2’ and the other via the ‘Kitchen’ and ‘Porch 1’) and only one is the shortest (the one via ‘Porch 2’). When there is more than one route of equal shortest size, your program should find them all.
Hint: For (b) consider finding all routes from Origin to Destination and then choose the list with smaller length (i.e. less visits). Once this list is found, try to add any
other lists of same length to the solution and return each list one by one.
Part 2. Routes with Costs
(a) Suppose that when we describe entry points we also specify the cost in a third parameter; the cost represents the number of steps to move from a place to another.
entry(‘Outside’, ‘Porch 1’,1).
entry(‘Outside’, ‘Porch 2’,1).
entry(‘Porch 1’, ‘Kitchen’,1).
entry(‘Porch 2’, ‘Living Room’,5).
entry(‘Kitchen’, ‘Living Room’,3).
entry(‘Living Room’, ‘Corridor’,1).
entry(‘Corridor’, ‘WC’,2).
entry(‘Corridor’, ‘Master Bedroom’,2).
entry(‘Corridor’, ‘Bedroom’,2).
Rewrite Part 1 (a) to define route(Origin, Destination, Route, Cost), a new program that returns the total Cost of a Route, when searching to move from Origin to Destination. For example, if you ask the query?- route(‘Outside’, ‘Living Room’, Route, Cost). you should get the following answers with your program:
Route = [‘Outside’, ‘Porch 1’, ‘Kitchen’, ‘Living Room’], Cost = 5 ;
Route = [‘Outside’, ‘Porch 2’, ‘Living Room’]
Cost = 6 ;
false.
Test your program by asking different queries and see whether your work produces the expected outcomes.
This CS2910 - IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.