In this code:
apply_constraints(MatchA, MatchB, PotentialMatches, RemainingMatches, Day) :-
different_teams(MatchA, MatchB),
can_play(MatchA, morning, Day),
can_play(MatchB, morning, Day),
subtract(PotentialMatches, [MatchA, MatchB], RemainingMatches).
the second can_play
clause should be checking the afternoon rather than the morning. This would be more obvious if the games were called MorningMatch
and AfternoonMatch
rather than MatchA
and MatchB
.