Frequently Asked Questions: Q: Some rules of the game in A3 are not completely specified. A: In this case choose the interpretation you prefer. All plausible interpretations will be considered OK. One good interpretation is: check for all_figures in the two cards of the current round and give 5 points for the round if the condition is true. For the ace of clubs and the rule about the opponent having zero points, apply them to the accumulated score, just after you add the score of the current round. If both players have zero points, give 10 points to both. Q: How to generate random numbers in A3? A: random(+Int) generates a random integer between 0 and Int. It uses the system clock to generate different numbers. Example of use: ?- X is random(10). X = 1 ?- X is random(10). X = 7 Q: How to use a random number to pick cards? A: You need to generate a random number between zero and the number of cards left in the game. One way to keep track of the cards is to generate a list with all of them at the beginning of the game, and take out cards as the game goes. You can use the builtin predicate nth1 to extract the element of given index from a list nth1(Index, List, Elem). Q: Hints for A2 part 6. If the list of courses is [[a,b], [b,c,d], [a,b,b]], how do you transform it into a flat list with only one occurrence of each element? A: You can choose one of two solutions. You can flatten the list into [a,b,b,c,d,a,b,b], using the builtin predicate flatten, or a recursive method that uses append. Then you need to eliminate multiple occurrences and keep only one of them. You can do this by looking if the head of the list is member in the tail, if it is skip the element, if not keep it. In this way you keep the last occurrence. The result would be [c,d,a,b]. Or you can use a version with accumulator that keeps the first occurrence, and the result would be [a,b,c,d]. Another solution is to use two predicates, both carrying the extra parameter that accumulates the result. Initially you can place in the accumulator the first sublist list. So, you have a predicate to go through the list till the end and another predicate to go through a sublist list till the end. Each of them will have a base case that copies the accumulated list into the result when reaching []. If an element is member in the accumulator, you skip it, otherwise you add it to the accumulator. In the way you keep the first occurrence. The result would be [a,b,c,d].