Question: te a Prolog program q 2 _ game.pl that solves this problem using interleaving of generate and test technique considered in class. In your programs,

te a Prolog program q2_game.pl that solves this problem using interleaving of generate and test technique considered in class. In your programs, the variables should range over the following finite domain of characters: n (a team did not participate in a round), l (loss), d (draw), w (win). You will need to be careful in your program regarding the order of constraints. Also, provide comments where in your program which constraint is implemented. Explain briefly the ordering you have chosen (write comments in you program file). You should implement both a solve and solve and print as described in question 1. Make sure that solve and print has no arguments and prints the answers returned by your program in an easy to read format: you will lose marks if output is obscure. Arrange your output similar to the predicate print solution(List) discussed in class. The TA should be able to call both your predicate solve(List) and your predicate solve and print to see the solution. Before, you write a program that solves this CSP, implement the 2-argument predicate fourExactly(X,List) and use it in your program. Specifically, this predicate can be useful when you implement the 4th constraint: the list of points awarded to the teams has exactly 4 occurrences of d. This predicate is true, if X occurs exactly four times in the given List. In your implementation, do not make assumptions about the number or kind of elements in List. This is because we will test your predicate independently of your solution. For example, 3 fourExactly(q,[q,a,b,q,q,b,q,a,c,b,c] should succeed. You might wish to introduce additional helping predicates to implement constraints. In any case, you have to implement all your helping predicates yourself. You cannot use any of the library predicates, unless they were discussed in class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!