Fixes scoring (Total Score instead of Ranked Score)

Also ensures that last_player -> first_player rules are met
This commit is contained in:
Nemo 2020-06-11 19:24:22 +05:30
parent b90bbcebf4
commit 5ea0e8239c
5 changed files with 60 additions and 4 deletions

View File

@ -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

View File

@ -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};

35
project.mzp Normal file
View File

@ -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
}

View File

@ -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))));
@ -13,3 +16,7 @@ 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)[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);
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
);

View File

@ -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]
)
);