-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwc.pl
86 lines (73 loc) · 2.09 KB
/
wc.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
% Correct score
points(Name, 7) :-
prediction(Name, Teams, PredScores, _PredResult),
match(group, Teams, PredScores, _Result).
% Incorrect score, correct winner
points(Name, 2) :-
prediction(Name, Teams, PredScores, PredResult),
match(group, Teams, Scores, PredResult),
PredScores \= Scores.
% Incorrect score, points correct
points(Name, 1) :-
prediction(Name, Teams, PredScore1-PredScore2, _PredResult),
match(group, Teams, PredScore1-Score2, _Result),
PredScore2 \= Score2.
points(Name, 1) :-
prediction(Name, Teams, PredScore1-PredScore2, _PredResult),
match(group, Teams, Score1-PredScore2, _Result),
PredScore1 \= Score1.
% Selected team won
points(Name, 5) :-
selected_team(Name, Team),
match(_Stage, _Teams, _Scores, Team).
% Selected team drawed
points(Name, 3) :-
selected_team(Name, Team),
match(_Stage, Team-_Team2, _Scores, draw).
points(Name, 3) :-
selected_team(Name, Team),
match(_Stage, _Team1-Team, _Scores, draw).
% Selected team lost
points(Name, 1) :-
selected_team(Name, Team),
match(_Stage, Team-Team2, _Scores, Team2).
points(Name, 1) :-
selected_team(Name, Team),
match(_Stage, Team1-Team, _Scores, Team1).
% Points for goals scored
points(Name, Points) :-
selected_team(Name, Team),
match(_Stage, Team-_Team2, Points-_Score2, _Result).
points(Name, Points) :-
selected_team(Name, Team),
match(_Stage, _Team1-Team, _Score1-Points, _Result).
% Correct qualifier
points(Name, 2) :-
selected_qualifier(Name, Team),
qualifier(Team).
% Correct finalists
points(Name, 7) :-
selected_finalist(Name, Team),
finalist(Team).
points(Name, 1) :-
selected_finalist(Name, Team1),
selected_finalist(Name, Team2),
Team1 \= Team2,
finalist(Team1),
finalist(Team2).
% Sum of a list
sum([], 0).
sum([E|L], Sum) :-
sum(L, Sum2),
Sum is Sum2 + E.
% All points for a person
all_points(Name, AllPoints) :-
name(Name),
findall(Points, points(Name, Points), PointList),
sum(PointList, AllPoints).
:- include('data/data.pl').
wc :-
setof(P-N, all_points(N, P), List),
member(Points-Name, List),
format("~6a : ~d~n", [Name, Points]),
fail.