Fixes the max cards being repeated issue, adds awards

pull/1/head
Nemo 3 years ago
parent 60eb7732d4
commit 86cff25f11
  1. 62
      modernart-game.mzn
  2. 26
      modernart.mzn

@ -25,29 +25,61 @@ 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) (
score_per_round_per_player[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])
);
% Decide the top 3 artists by picikng the cards per artist for that round, and sorting them, then slice to get top 3
constraint forall(r in Rounds)(row(top_3_artists_per_round,r)= reverse(arg_sort(row(cards_per_artist_per_round, Round1)))[1..3]);
% Max number of visible cards can be 6 for any artist per player
var 5..6: max_visible_cards;
constraint max_visible_cards = if card(Players)>2 then 6 else 5 endif;
% Maximum max_visible_cards of the artist with maximum cards
constraint forall(r in Rounds) (max(row(cards_per_artist_per_round,r)) = max_visible_cards);
% second highest value should not be the max
constraint forall(r in Rounds) (sort(row(cards_per_artist_per_round, r))[4] != max_visible_cards);
% Top three artists get ranking score in each round as 3,2,1
constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(top_3_artists_per_round,r)[1]] = 3);
constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(top_3_artists_per_round,r)[2]] = 2);
constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(top_3_artists_per_round,r)[3]] = 1);
% Decide the top artists by picikng 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(cards_per_artist_per_round, r))));
% Max number of visible cards can be 6
constraint forall(r in Rounds, p in Players, a in Artists) (visible_count_per_round_per_artist_per_player[r,p,a] <=6);
constraint forall(r in Rounds, p in Players, a in Artists) (visible_count_per_round_per_artist_per_player[r,p,a] >=0);
% Top three artists get ranking score in each round as 3,2,1 others get 0
constraint forall(r in Rounds) (ranking_score_per_artist_per_round[r, row(sorted_artists_per_round,r)[1]] = 3);
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);
% AWARDS
% Total number of awards for each artist = 1
constraint forall(a in Artists) ( sum(col(awards_per_round_per_artist,a)) = 1 );
% awards can only be given if an artist's card was played that turn
constraint forall(r in Rounds, a in Artists) (
awards_per_round_per_artist[r,a] = 1 -> cards_per_artist_per_round[r,a] > 0
);
% 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] =
if awards_per_round_per_artist[r,a] then
ranking_score_per_artist_per_round[r,a] + 2
else
ranking_score_per_artist_per_round[r,a]
endif
);
% constraint forall(r in Rounds, a in Artists) (
% awards_per_round_per_artist
% );
% 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);
% array[1..5] of var Artists: artists_sorted_by_count_round1;
% constraint alldifferent(artists_sorted_by_count_round1);
% constraint artists_sorted_by_count_round1 = reverse(arg_sort(row(cards_per_artist_per_round, Round1)));
% output [show_int(reverse(arg_sort(row(cards_per_artist_per_round, Round1))))];

@ -3,26 +3,30 @@ enum Players;
enum Artists;
enum Rounds;
Players = { Nemo, Jana };
Players = { Nemo, Jana, Adam};
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;
% 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;
% Winning artists for each round
array[Rounds,1..3] of var Artists: top_3_artists_per_round;
% Total points that an artist has in a given round
array[Rounds,Artists] of var int: total_score_per_round_per_artist;
% Total number of a cards of an artist that were PLAYED this round
array[Rounds, Artists] of var int: cards_per_artist_per_round;
% Whether an artist won an award in a given round
array[Rounds,Artists] of var bool: awards_per_round_per_artist;
% constraint forall(a,b in Artists, r in Rounds) (
% Winning artists for each round (just-by-ranking)
array[Rounds,1..card(Artists)] of var Artists: sorted_artists_per_round;
array[Rounds,Players] of var int: score_per_round_per_player;
% );
% Total number of a cards of an artist that were PLAYED this round
array[Rounds, Artists] of var int: cards_per_artist_per_round;
% solve maximize visible_count_per_round_per_artist_per_player[LiteMetal, Nemo, Round1] +
% visible_count_per_round_per_artist_per_player[Krypto, Nemo, Round1] +
% visible_count_per_round_per_artist_per_player[Yoko, Nemo, Round1] +
% visible_count_per_round_per_artist_per_player[ChristinP, Nemo, Round1];
% Dumb constraints to help maximize score
constraint score_per_round_per_player[Round1,Nemo] > score_per_round_per_player[Round1,Jana];
constraint score_per_round_per_player[Round1,Jana] > 15;
solve maximize score_per_round_per_player[Round1,Nemo];
Loading…
Cancel
Save