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
Squares.

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.
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 ueensu.ca/home/cisc260/2014w/assig nments/assn6/assn6.html

21