From 8cc6f0d74514e00cd30fc655081b244f9ba9b296 Mon Sep 17 00:00:00 2001 From: Nemo Date: Thu, 11 Jun 2020 00:14:01 +0530 Subject: [PATCH] Adds lots of features --- functions.mzn | 0 modernart-game.mzn | 63 ++++++++++++++++++++++++++++++++------------ modernart-sanity.mzn | 16 +++++++++++ modernart.mzn | 12 ++++++++- 4 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 functions.mzn create mode 100644 modernart-sanity.mzn diff --git a/functions.mzn b/functions.mzn new file mode 100644 index 0000000..e69de29 diff --git a/modernart-game.mzn b/modernart-game.mzn index 04451bf..6af6618 100644 --- a/modernart-game.mzn +++ b/modernart-game.mzn @@ -1,5 +1,6 @@ include "alldifferent.mzn"; include "globals.mzn"; +include "modernart-sanity.mzn"; % Constraints per artist % TODO: This is also TOTAL card limit, not visible @@ -15,24 +16,11 @@ constraint sum(p in Players, r in Rounds) (visible_count_per_round_per_artist_pe constraint sum(p in Players, r in Rounds) (visible_count_per_round_per_artist_per_player[r,p,KarlGitter])>=0; constraint sum(p in Players, r in Rounds) (visible_count_per_round_per_artist_per_player[r,p,Krypto])>=0; -% Score sanity per round -constraint forall (a in Artists, r in Rounds) ( - ranking_score_per_artist_per_round[r,a] >=0 -); - % Calculate total cards of an artist played per round constraint forall (a in Artists, r in Rounds) ( cards_per_artist_per_round[r, a] = sum(p in Players) (visible_count_per_round_per_artist_per_player[r,p,a]) ); -% Sanity check -constraint forall (a in Artists, r in Rounds) ( - cards_per_artist_per_round[r,a]>=0 -); -% So they don't go negative -constraint forall (a in Artists, r in Rounds, p in Players) ( - visible_count_per_round_per_artist_per_player[r,p, a]>=0 -); % Calculate total score per player constraint forall(r in Rounds, p in Players) ( @@ -68,6 +56,16 @@ constraint forall(r in Rounds, a in Artists) ( awards_per_round_per_artist[r,a] = 1 -> cards_per_artist_per_round[r,a] > 0 ); +% DOUBLE CARDS +% - Double cards are counted as VISIBLE +% - Double cards CANNOT breach the 6 LIMIT +% Total number of DOUBLE CARDS for each artist = 1 +% FOR EVERY ROUND+ARTIST combination, only 1 player should have played a double card +% TODO: Check if this is still correct after a second round +constraint forall(a in Artists) ( + sum(p in Players, r in Rounds) (double_played[r,p,a]) = 1 +); + % Score = ranking_score + award_score if an award was given this round constraint forall(r in Rounds, a in Artists) ( total_score_per_round_per_artist[r,a] = @@ -78,11 +76,42 @@ constraint forall(r in Rounds, a in Artists) ( endif ); -% constraint forall(r in Rounds, a in Artists) ( -% awards_per_round_per_artist +array[Rounds,Players] of var int: max_cards_per_round_per_player; + +% What is the extra cards you can possibly play +array[Rounds,Players,Artists] of var bool: bonus_due_to_double_cards; + +constraint forall(a in Artists, r in Rounds, p in Players) ( + % If this player played more than 2 cards of this artist + if visible_count_per_round_per_artist_per_player[r,p,a] >=2 + % And this artist is the winning artist this round + /\ row(sorted_artists_per_round,r)[1] = a + % And you closed this round + /\ visible_count_per_round_per_artist_per_player[r,p,a] = max_visible_cards + % and they are claiming their double now + /\ double_played[r,p,a] then + bonus_due_to_double_cards[r,p,a] = true + else + bonus_due_to_double_cards[r,p,a] = false + endif +); + +% array[Rounds,Players] of var int: negs_due_to_double_cards; + +% constraint forall(r in Rounds, p in Players) ( + % ); +% Calculate maximum cards any player can play in first round +constraint forall(p in Players) ( + max_cards_per_round_per_player[Round1,p] = 13 +); + % TODO: This is actual not VISIBLE, but TOTAL cards LIMIT % TODO: This does not consider any of the symbols -% You can max play 13 cards in Round 1 -constraint forall(p in Players) (sum(a in Artists) (visible_count_per_round_per_artist_per_player[Round1,p,a]) <=13); +% IMPLIED RULE: You can max play 13 cards in Round 1 +constraint forall(p in Players) ( + sum(a in Artists) ( + visible_count_per_round_per_artist_per_player[Round1,p,a] + ) <= max_cards_per_round_per_player[Round1,p] +); diff --git a/modernart-sanity.mzn b/modernart-sanity.mzn new file mode 100644 index 0000000..5824b5f --- /dev/null +++ b/modernart-sanity.mzn @@ -0,0 +1,16 @@ +% Sanity check +constraint forall (a in Artists, r in Rounds) ( + cards_per_artist_per_round[r,a]>=0 +); +% So they don't go negative +constraint forall (a in Artists, r in Rounds, p in Players) ( + visible_count_per_round_per_artist_per_player[r,p, a]>=0 +); + +% Score sanity per round +constraint forall (a in Artists, r in Rounds) ( + ranking_score_per_artist_per_round[r,a] >=0 +); + +% Round 1 Player 1 +constraint first_player[Round1] = Nemo; \ No newline at end of file diff --git a/modernart.mzn b/modernart.mzn index d65f585..ab0979e 100644 --- a/modernart.mzn +++ b/modernart.mzn @@ -3,21 +3,31 @@ enum Players; enum Artists; enum Rounds; -Players = { Nemo, Jana, Adam}; +Players = { Nemo, Jana}; Artists = {Krypto,KarlGitter,ChristinP,Yoko,LiteMetal}; Rounds = {Round1}; % Number of cards per round per player per artist array[Rounds,Players,Artists] of var int: visible_count_per_round_per_artist_per_player; +% First player every Round +array[Rounds] of var Players: first_player; + +% Closing player every Round +array[Rounds] of var Players: last_player; + % How much score was made by each artist in each round by just RANKING array[Rounds,Artists] of var int: ranking_score_per_artist_per_round; + % Total points that an artist has in a given round array[Rounds,Artists] of var int: total_score_per_round_per_artist; % Whether an artist won an award in a given round array[Rounds,Artists] of var bool: awards_per_round_per_artist; +% Whether you played a double this round +array[Rounds,Players,Artists] of var bool: double_played; + % Winning artists for each round (just-by-ranking) array[Rounds,1..card(Artists)] of var Artists: sorted_artists_per_round;