You are on page 1of 3

Assignment 6: CISC 260 Winter 2014

a legal path through the hopscotch board containing the number of points in the list

2. Write a predicate called betterpath, where betterpath(pathi,path2,Better) means
that Better is either pathi or Path2 and is the path with the greater total number of
points. If pathi and Path2 have the same total number of points, Better can be either
one. Hint: the SWI-Prolog library contains a predicate called sum list, where
sum_iist (List, sum) means that if List is a list of numbers sum is the sum of all the
numbers in the list.
3. Write a predicate called bestpathofList, where bestpathofList (ListofPaths,Path)
means that path is the path in Listof Paths with the greatest total number of points. If
there is a tie, you can resolve it however you like.
4. Use setof and your legaipath predicate to build a list of all the legal paths through a
hopscotch board. Then use bestpathofList to find the best path in that list of paths. (I
discussed the setof predicate in class on Friday, March 21. For the large number of you
who weren't in class, you can wait for the video which will be posted on Saturday the
22nd, or look up setof in your text.)
This is not the only way to solve the problem. Any hopscotch predicate that words correct for
all our test cases will receive full marks. If you're having trouble, though, this is a suggestion
for breaking down the problem, and we will give partial credit if you can get some of those
helper predicates working even if they don't all work.
Administrative Details:
To make it simpler for us to mark your assignments, you must put your hopscotch predicate,
plus helpers (if any) into a single file called Assignments.pi.
Marking Scheme:
This assignment will be marked out of 16 points. If you use the breakdown suggested above,
we will divide the points as follows:
legaipath: 4
betterPath: 4
bestPathOfList: 4

putting everything together to create a correct hopscotch predicate: 4
If you solve the problem a different way, you get all 16 points for a hopscotch predicate that
works correct with all of our test cases. If you didn't manage to get a working hopscotch
predicate, we'll give you partial credit according to how far you got.
Remember that we may deduct an administrative penalty if you do not follow the instructions
in the Assignment Requirements page.
There are no style points for this assignment, but as always if you discipline yourself to write
clearly, with meaningful names for your predicates and parameters -- and even include a few
http://research.cs.q nments/assn6/assn6.html


Identifying yourself in the header comment is important to help us make sure that the right mark goes to the right person.hs contains several examples of hopscotch boards and their best paths. just to make sure that your functions aren't tailored specifically to these examples. Ontario.queensu.html . it's particularly important that you give a clear explanation for what each of your helper predicates is supposed to will help you keep things straight and get your code working. we will deduct an administrative penalty. If you follow a different scheme than the one I suggested above and it's not all working. the header comment at the beginning of the program is a requirement.cs. The TAs will be using different examples to tes your predicate. Some Examples: AssnZExamples. This page maintained by Margaret Lamb. so that we can evaluate each one separately. Queen's University. Kingston. They apply to this assignment too. Last modified 03/22/2014 02:34:29 http://research.3/21/2014 Assignment 6: CISC 260 Winter 2014 comments -. Even though you won't earn style points for this assignment. It also makes it easier for you to get help when you need it. If you don't have a comment at the beginning identifying yourself (by student number or NetID) and the other members of your group if applicable.

Write a predicate called legaipath.1. on Saturday. Best = [7. there are some aspects of Prolog that make this problem simpler to solve (at least. In Prolog.q ueensu. Here is an example using my solution: I ?. 3] . though. These detail all of the general administrative stuff you need to know about assignments for this course. And finally. Please make sure you have read the general Assignment Requirements for CISC 260 before beginning this assignment.Best). If you're having trouble.html 1/3 .2. Kingston. you must solve the same Hopscotch puzzle as you did for Assignment 2. path) means that Path is the best legal path through a hopscotch board if the squares in the board contain the numbers of points in the list squares. take a deep breath! First. By best nments/assn6/assn6.m. If you found Assignment 2 difficult. where hopscotch (squares. false.9. Winter 2014 Queen's University. you will get full correctness points. what is required.6.5. Instead of re-stating the basic problem.hopscotch([7. March 29 General questions about this assignment (administrative details. so I don't have to repeat them for each assignment. For this assignment. Please help your fellow students find Q&A about this assignment by using this designated forum rather than the general forum.cs. but this time you must do it in Prolog. just the path. If your hopscotch predicate works without error. where legaipath (squares. You don't have to indicate the total number of points. I'll refer you to the explanation given with Assignment 2.3/21/Z014 Assignment 6: CISC 260 Winter 2014 Assignment 6: Hopscotch In Prolog CISC 260. you can pattern your solution after the Haskell solution I've posted on Moodle so you have a head start. here is a suggested strategy: 1. 5. 6.3]. You may assume that the first parameter of hopscotch will be bound. what you must write is a predicate called hopscotch. I mean the path with the largest total number of points. Path) means that path is http://research. Ontario back to CISC 260 Moo die site This Assignment is due by 8 a. etc) should be directed to the Assignment 6 Moodle forum.4. in my opinion). It helps you think about what ideas are common between the two and what's different. Please do not post Prolog code or even pseudo-code on Moodle. I think it's a very useful experience to solve the same problem in both languages. Second.