diff --git a/gameplay.mzn b/gameplay.mzn index 9c6c60a..e84c224 100644 --- a/gameplay.mzn +++ b/gameplay.mzn @@ -28,8 +28,8 @@ var 5..6: MaxVisibleCards; constraint MaxVisibleCards = if card(Players)>2 then 6 else 5 endif; % Maximum MaxVisibleCards of the artist with maximum cards +% TODO: Replace with at_most, if this isn't cleaned up after simultaneous constraint forall(r in Rounds) (max(row(CardsForArtist,r)) = MaxVisibleCards); - % second highest value should not be the max constraint forall(r in Rounds) (sort(row(CardsForArtist, r))[4] != MaxVisibleCards); @@ -80,6 +80,11 @@ var set of Players: Px2; var set of Players: Px3; var set of Players: Px4; +% First player in all future rounds is determined by the next player from the player who finished previous round +constraint first_player[Round2] = if last_player[Round1] = card(Players) then 1 else enum_next(Players, last_player[Round1]) endif; +constraint first_player[Round3] = if last_player[Round2] = card(Players) then 1 else enum_next(Players, last_player[Round2]) endif; +constraint first_player[Round4] = if last_player[Round3] = card(Players) then 1 else enum_next(Players, last_player[Round3]) endif; + constraint Pn1 = if (first_player[Round1] < last_player[Round1]) then first_player[Round1]..last_player[Round1] else diff --git a/modernart.mzn b/modernart.mzn index 7a9822e..ae47b6a 100644 --- a/modernart.mzn +++ b/modernart.mzn @@ -4,6 +4,9 @@ enum Artists; enum Rounds; Players = {Nemo, Jana, Adam}; +% The order here is opposite of what you'd usually use while playing the game +% because this results in LiteMetal getting a higher numeric value and that makes +% sorting much easier Artists = {Krypto,KarlGitter,ChristinP,Yoko,LiteMetal}; Rounds = {Round1, Round2, Round3, Round4}; diff --git a/project.mzp b/project.mzp new file mode 100644 index 0000000..4de317e --- /dev/null +++ b/project.mzp @@ -0,0 +1,35 @@ +{ + "builtinSolverConfigs": [ + ], + "openFiles": [ + "artists.mzn", + "awards.mzn", + "dealing.mzn", + "double.mzn", + "functions.mzn", + "gameplay.mzn", + "modernart.mzn", + "ranking.mzn", + "ranking.mzn", + "sanity.mzn", + "scoring.mzn" + ], + "openTab": 10, + "projectFiles": [ + "artists.mzn", + "awards.mzn", + "dealing.mzn", + "double.mzn", + "functions.mzn", + "gameplay.mzn", + "modernart.mzn", + "ranking.mzn", + "sanity.mzn", + "scoring.mzn" + ], + "projectSolverConfigs": [ + ], + "selectedBuiltinConfigId": "org.gecode.gecode", + "selectedBuiltinConfigVersion": "6.1.1", + "version": 105 +} diff --git a/ranking.mzn b/ranking.mzn index f4d1232..da6f409 100644 --- a/ranking.mzn +++ b/ranking.mzn @@ -4,6 +4,9 @@ array[Rounds,Artists] of var int: ranking_score_per_artist_per_round; % Winning artists for each round (just-by-ranking) array[Rounds,1..card(Artists)] of var Artists: sorted_artists_per_round; +% Is any artist ranked in this round or not +array[Rounds,Artists] of var bool: IsArtistRanked; + % Decide the top artists by picking the cards per artist for that round, and sorting them constraint forall(r in Rounds)(row(sorted_artists_per_round,r)= reverse(arg_sort(row(CardsForArtist, r)))); @@ -12,4 +15,8 @@ constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted_artists_per_round,r)[2]] = 2); constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted_artists_per_round,r)[3]] = 1); constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted_artists_per_round,r)[4]] = 0); -constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted_artists_per_round,r)[5]] = 0); \ No newline at end of file +constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted_artists_per_round,r)[5]] = 0); + +constraint forall(r in Rounds, a in Artists) ( + IsArtistRanked[r,a] = if ranking_score_per_artist_per_round[r,a] > 0 then true else false endif +); \ No newline at end of file diff --git a/scoring.mzn b/scoring.mzn index b270cdb..0c0635f 100644 --- a/scoring.mzn +++ b/scoring.mzn @@ -15,12 +15,18 @@ constraint forall(r in Rounds, a in Artists) ( total_score_per_round_per_artist[enum_prev(Rounds, r),a] endif ); -% Calculate total score per player +% This is same as total_score but force set to zero if the artist is not ranked +% This is what each player gets for each card they play +array[Rounds,Artists] of var int: ArtistScore; +constraint forall(r in Rounds, a in Artists) ( + ArtistScore[r,a] = if IsArtistRanked[r,a] then total_score_per_round_per_artist[r,a] else 0 endif +); +% Calculate total score per player % 1. Per Round constraint forall(r in Rounds, p in Players) ( RoundScore[r,p] = sum(a in Artists) ( - visible_count_per_round_per_artist_per_player[r,p,a] * ranking_score_per_artist_per_round[r,a] + visible_count_per_round_per_artist_per_player[r,p,a] * ArtistScore[r,a] ) );