[SOLVED] 代写 prolog COMP3109 Assignment 3 LogicOriented Programming 10 marks

30 $

File Name: 代写_prolog_COMP3109_Assignment_3_LogicOriented_Programming_10_marks.zip
File Size: 659.4 KB

SKU: 0037390862 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


COMP3109 Assignment 3 LogicOriented Programming 10 marks
This third assignment is an individual assignment and is due in Week 14 on on Monday, midnight. Please pack the source code of this assignment into a zip file and submit it via Canvas. The doc umentation of the program should be done in the form of comments. Please be verbose with your comments, i.e., explain your ideas thoroughly, saying in plain English how you have implemented the program. Not complying to documentation standards will give you fewer marks for your assign ment. In this assignment, you will implement a Puzzle solver in Prolog. Assume that Agatha, Berta, Cristoph, and David are trapped on an island and it is dark. The island is connected to the mainland via a bridge. To escape from the island, Agatha, Berta, Cristoph, and David must walk over this bridge. However, the bridge is fragile and cannot sustain the weight of more than two people at the same time. Agatha, Berta, Christoph, and David have a single torch they can use to walk over the bridge. A torch is needed to walk safely over the bridge. The problem is that the torch will be burned in 60 minutes. The Agatha, Berta, Christoph, and David have different fitness levels and their times to cross the bridge varies. It takes Agatha 5 minutes, Berta 10 minutes, Christoph 20 minutes, and David 25 minutes. Since there can be only two people on the bridge at the same time, they cannot cross the bridge all at once. Since they need the torch for crossing the bridge all the time because it is dark, whenever two have crossed the bridge, somebody has to walk back over the bridge and bring the torch to the remaining people on the island.
The problem now is: In which order can the four people cross the bridge in time that is, in 60 minutes to be saved from the island?
Task 1 Implement this search problem in SWIProlog 7 points
Writing the Prolog code for this problem is straight forward as soon as you get the modelling right i.e. which predicate you need to solve the puzzle. I suggest having a predicate that has facts about the walking speed of each person on the island, e.g., walktime2. For example,
walktimeAgatha, 5.
walktimeBertha, 10.
walktimeChristoph, 20.
walktimeDavid, 25.
and perhaps a predicate reflecting the people in the form of a list.
You need to find a state description for the bridge crossings. A possible state description is that you have two lists for the island and the mainland describing the location of the people in this state, the expired time so far, and where the torch is located i.e., either island or mainland. This can be done in the form of a functor.
1

Note that a state in this state description does not describe the transition from one side to the other side. You may want to introduce a transition predicate that captures the transfers from one state to the next state in a correct fashion. A correct transition is that 1 you have between two people swapping the sides from the island to the mainland and one person swapping the sides from the mainland to the island. The new state reflects the time consumed so far, and the position of the torch. Please be aware of the initial state, i.e., all people are on the island and, torch is on the island, and the time elapsed so far is set to zero.
Your program searches for a state for which all people have safely arrived at the mainland in less than or equal to 60 minutes.
Task 2 Implement this search problem in Souffl 3 points
You dont have the notion of lists. However, you have notions of records and other means to express the state.
COMP3109
Programming Languages and Paradigms Page 2 of 2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 prolog COMP3109 Assignment 3 LogicOriented Programming 10 marks
30 $