From 896df2ace373fe545be1cb0b40a7737a2c816711 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 9 Jan 2020 04:47:14 -0800 Subject: [PATCH 01/11] score instead of ranked choice --- .../configuration/configuration.dm | 2 +- code/controllers/subsystem/vote.dm | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 730a3f17f4..240f7de2d5 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -341,7 +341,7 @@ if(probabilities[M.config_tag]<=0) qdel(M) continue - if(M.config_tag in SSvote.stored_modetier_results && SSvote.stored_modetier_results[M.config_tag] < Get(/datum/config_entry/number/dropped_modes)) + if(!(M.config_tag in SSvote.stored_modetier_results)) qdel(M) continue if(min_pop[M.config_tag]) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index f82954276e..9603edacef 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -212,6 +212,7 @@ SUBSYSTEM_DEF(vote) calculate_condorcet_votes(vote_title_text) if(vote_system == SCORE_VOTING) calculate_majority_judgement_vote(vote_title_text) + calculate_scores(vote_title_text) var/list/winners = get_result() var/was_roundtype_vote = mode == "roundtype" || mode == "dynamic" if(winners.len > 0) @@ -219,13 +220,20 @@ SUBSYSTEM_DEF(vote) stored_gamemode_votes = list() if(!obfuscated && vote_system == RANKED_CHOICE_VOTING) text += "\nIt should be noted that this is not a raw tally of votes (impossible in ranked choice) but the score determined by the schulze method of voting, so the numbers will look weird!" - for(var/i=1,i<=choices.len,i++) - var/votes = choices[choices[i]] - if(!votes) - votes = 0 - if(was_roundtype_vote) - stored_gamemode_votes[choices[i]] = votes - text += "\n[choices[i]]: [obfuscated ? "???" : votes]" //CIT CHANGE - adds obfuscated votes + if(mode == "mode tiers") + for(var/score_name in scores) + var/score = scores[score_name] + if(!score) + score = 0 + text = "\n[score_name]: [obfuscated ? "???" : score]" + else + for(var/i=1,i<=choices.len,i++) + var/votes = choices[choices[i]] + if(!votes) + votes = 0 + if(was_roundtype_vote) + stored_gamemode_votes[choices[i]] = votes + text += "\n[choices[i]]: [obfuscated ? "???" : votes]" //CIT CHANGE - adds obfuscated votes if(mode != "custom") if(winners.len > 1 && !obfuscated) //CIT CHANGE - adds obfuscated votes text = "\nVote Tied Between:" @@ -276,7 +284,7 @@ SUBSYSTEM_DEF(vote) if(CONFIG_GET(flag/modetier_voting)) reset() started_time = 0 - initiate_vote("mode tiers","server",hideresults=FALSE,votesystem=RANKED_CHOICE_VOTING,forced=TRUE, vote_time = 30 MINUTES) + initiate_vote("mode tiers","server",hideresults=FALSE,votesystem=SCORE_VOTING,forced=TRUE, vote_time = 30 MINUTES) to_chat(world,"The vote will end right as the round starts.") return . if("restart") @@ -290,7 +298,13 @@ SUBSYSTEM_DEF(vote) else GLOB.master_mode = . if("mode tiers") - stored_modetier_results = choices.Copy() + var/list/raw_score_numbers = list() + for(var/score_name in scores) + sorted_insert(raw_score_numbers,scores[score_name],/proc/cmp_numeric_asc) + stored_modetier_results = scores.Copy() + for(var/score_name in stored_modetier_results) + if(stored_modetier_results[score_name] <= raw_score_numbers[CONFIG_GET(number/dropped_modes)]) + stored_modetier_results -= score_name if("dynamic") if(SSticker.current_state > GAME_STATE_PREGAME)//Don't change the mode if the round already started. return message_admins("A vote has tried to change the gamemode, but the game has already started. Aborting.") From c6507d47e2c797578a98d6fab1dd2fcdc037afba Mon Sep 17 00:00:00 2001 From: Putnam Date: Fri, 10 Jan 2020 20:06:35 -0800 Subject: [PATCH 02/11] bad patches, ugh --- code/controllers/subsystem/vote.dm | 38 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 9603edacef..e0ec031183 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -102,17 +102,18 @@ SUBSYSTEM_DEF(vote) var/list/d[][] = new/list(choices.len,choices.len) // the basic vote matrix, how many times a beats b for(var/ckey in voted) var/list/this_vote = voted[ckey] - for(var/a in 1 to choices.len) - for(var/b in a+1 to choices.len) - var/a_rank = this_vote.Find(a) - var/b_rank = this_vote.Find(b) - a_rank = a_rank ? a_rank : choices.len+1 - b_rank = b_rank ? b_rank : choices.len+1 - if(a_rank Date: Fri, 10 Jan 2020 23:33:26 -0800 Subject: [PATCH 03/11] another dumb patch --- code/controllers/subsystem/vote.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index e0ec031183..3e9c3a923e 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -256,8 +256,9 @@ SUBSYSTEM_DEF(vote) if(RANKED_CHOICE_VOTING) for(var/i=1,i<=voted.len,i++) var/list/myvote = voted[voted[i]] - for(var/j=1,j<=myvote.len,j++) - SSblackbox.record_feedback("nested tally","voting",1,list(vote_title_text,"[j]\th",choices[myvote[j]])) + if(islist(myvote)) + for(var/j=1,j<=myvote.len,j++) + SSblackbox.record_feedback("nested tally","voting",1,list(vote_title_text,"[j]\th",choices[myvote[j]])) if(obfuscated) //CIT CHANGE - adds obfuscated votes. this messages admins with the vote's true results var/admintext = "Obfuscated results" if(vote_system == RANKED_CHOICE_VOTING) From 9d3873f26fae7d12fa11e90748a1aa8bbfe080c1 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 11 Jan 2020 03:32:14 -0800 Subject: [PATCH 04/11] traitor always available --- code/controllers/subsystem/vote.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 3e9c3a923e..022943351d 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -433,6 +433,7 @@ SUBSYSTEM_DEF(vote) for(var/tag in modes_to_add) if(probabilities[tag] <= 0) modes_to_add -= tag + modes_to_add -= "traitor" // makes it so that traitor is always available choices.Add(modes_to_add) if("dynamic") for(var/T in config.storyteller_cache) From 85f6367df554cac2bb6da5241d9a04d38cdab241 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 11 Jan 2020 03:50:19 -0800 Subject: [PATCH 05/11] weh --- code/controllers/subsystem/vote.dm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 022943351d..97672da363 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -151,7 +151,8 @@ SUBSYSTEM_DEF(vote) sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) // START BALLOT GATHERING pretty_vote += choice - pretty_vote[choice] = GLOB.vote_score_options[this_vote[choice]] + if(this_vote[choice] in GLOB.vote_score_options) + pretty_vote[choice] = GLOB.vote_score_options[this_vote[choice]] SSblackbox.record_feedback("associative","voting_ballots",1,pretty_vote) // END BALLOT GATHERING for(var/score_name in scores_by_choice) @@ -191,7 +192,8 @@ SUBSYSTEM_DEF(vote) for(var/ckey in voted) var/list/this_vote = voted[ckey] for(var/choice in this_vote) - sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) + if(choice in scores_by_choice) + sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) var/middle_score = round(GLOB.vote_score_options.len/2,1) for(var/score_name in scores_by_choice) var/list/score = scores_by_choice[score_name] From 37c611970815e4f424cd84c64d39ae013c78964b Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 11 Jan 2020 18:26:32 -0800 Subject: [PATCH 06/11] Sanity this is a commit by jimmy buffett --- code/controllers/subsystem/vote.dm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 97672da363..d1c8ec56be 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -143,16 +143,18 @@ SUBSYSTEM_DEF(vote) // https://en.wikipedia.org/wiki/Majority_judgment var/list/scores_by_choice = list() for(var/choice in choices) + scores_by_choice += choice scores_by_choice[choice] = list() for(var/ckey in voted) var/list/this_vote = voted[ckey] var/list/pretty_vote = list() - for(var/choice in this_vote) - sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) - // START BALLOT GATHERING - pretty_vote += choice - if(this_vote[choice] in GLOB.vote_score_options) - pretty_vote[choice] = GLOB.vote_score_options[this_vote[choice]] + for(var/choice in choices) + if(choice in this_vote && choice in scores_by_choice) + sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) + // START BALLOT GATHERING + pretty_vote += choice + if(this_vote[choice] in GLOB.vote_score_options) + pretty_vote[choice] = GLOB.vote_score_options[this_vote[choice]] SSblackbox.record_feedback("associative","voting_ballots",1,pretty_vote) // END BALLOT GATHERING for(var/score_name in scores_by_choice) @@ -188,11 +190,12 @@ SUBSYSTEM_DEF(vote) /datum/controller/subsystem/vote/proc/calculate_scores(var/blackbox_text) var/list/scores_by_choice = list() for(var/choice in choices) + scores_by_choice += choice scores_by_choice[choice] = list() for(var/ckey in voted) var/list/this_vote = voted[ckey] - for(var/choice in this_vote) - if(choice in scores_by_choice) + for(var/choice in choices) + if(choice in this_vote && choice in scores_by_choice) sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) var/middle_score = round(GLOB.vote_score_options.len/2,1) for(var/score_name in scores_by_choice) From 0c64ea1351383bc084a03c8cfc4de7e7dbae04c9 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 11 Jan 2020 18:37:16 -0800 Subject: [PATCH 07/11] wow that was fucking dumb --- code/controllers/configuration/configuration.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 240f7de2d5..b0ed6e57af 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -341,7 +341,7 @@ if(probabilities[M.config_tag]<=0) qdel(M) continue - if(!(M.config_tag in SSvote.stored_modetier_results)) + if(CONFIG_GET(flag/modetier_voting) && !(M.config_tag in SSvote.stored_modetier_results)) qdel(M) continue if(min_pop[M.config_tag]) From 5dc5ddaa76ba627cbe499661b6d59174351cb880 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 11 Jan 2020 22:17:18 -0800 Subject: [PATCH 08/11] daddy compiler please stop hating me --- code/controllers/subsystem/vote.dm | 35 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index d1c8ec56be..6593c46fbe 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -143,18 +143,18 @@ SUBSYSTEM_DEF(vote) // https://en.wikipedia.org/wiki/Majority_judgment var/list/scores_by_choice = list() for(var/choice in choices) - scores_by_choice += choice - scores_by_choice[choice] = list() + scores_by_choice += "[choice]" + scores_by_choice["[choice]"] = list() for(var/ckey in voted) var/list/this_vote = voted[ckey] var/list/pretty_vote = list() for(var/choice in choices) - if(choice in this_vote && choice in scores_by_choice) - sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) + if("[choice]" in this_vote && "[choice]" in scores_by_choice) + sorted_insert(scores_by_choice["[choice]"],this_vote["[choice]"],/proc/cmp_numeric_asc) // START BALLOT GATHERING - pretty_vote += choice - if(this_vote[choice] in GLOB.vote_score_options) - pretty_vote[choice] = GLOB.vote_score_options[this_vote[choice]] + pretty_vote += "[choice]" + if(this_vote["[choice]"] in GLOB.vote_score_options) + pretty_vote["[choice]"] = GLOB.vote_score_options[this_vote["[choice]"]] SSblackbox.record_feedback("associative","voting_ballots",1,pretty_vote) // END BALLOT GATHERING for(var/score_name in scores_by_choice) @@ -190,13 +190,13 @@ SUBSYSTEM_DEF(vote) /datum/controller/subsystem/vote/proc/calculate_scores(var/blackbox_text) var/list/scores_by_choice = list() for(var/choice in choices) - scores_by_choice += choice - scores_by_choice[choice] = list() + scores_by_choice += "[choice]" + scores_by_choice["[choice]"] = list() for(var/ckey in voted) var/list/this_vote = voted[ckey] for(var/choice in choices) - if(choice in this_vote && choice in scores_by_choice) - sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) + if("[choice]" in this_vote && "[choice]" in scores_by_choice) + sorted_insert(scores_by_choice["[choice]"],this_vote["[choice]"],/proc/cmp_numeric_asc) var/middle_score = round(GLOB.vote_score_options.len/2,1) for(var/score_name in scores_by_choice) var/list/score = scores_by_choice[score_name] @@ -654,9 +654,20 @@ SUBSYSTEM_DEF(vote) SSpersistence.saved_votes[usr.ckey][mode] = list() voted[usr.ckey] = SSpersistence.saved_votes[usr.ckey][mode] if(islist(voted[usr.ckey])) - saved += usr.ckey + var/malformed = FALSE + if(vote_system == SCORE_VOTING) + for(var/thing in voted[usr.ckey]) + if(!(thing in choices)) + malformed = TRUE + if(!malformed) + saved += usr.ckey + else + to_chat(usr,"Your saved vote was malformed! Start over!") + SSpersistence.saved_votes[usr.ckey] -= mode + voted -= usr.ckey else to_chat(usr,"Your saved vote was malformed! Start over!") + voted -= usr.ckey else if(vote_system == SCORE_VOTING) submit_vote(round(text2num(href_list["vote"])),round(text2num(href_list["score"]))) From 295c134243eb2eb750a8ae0f406e8391b54e2282 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sun, 12 Jan 2020 03:06:17 -0800 Subject: [PATCH 09/11] i'm so dumb dude --- code/controllers/subsystem/vote.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 6593c46fbe..bb1d1c7e43 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -312,6 +312,7 @@ SUBSYSTEM_DEF(vote) for(var/score_name in stored_modetier_results) if(stored_modetier_results[score_name] <= raw_score_numbers[CONFIG_GET(number/dropped_modes)]) stored_modetier_results -= score_name + stored_modetier_results += "traitor" if("dynamic") if(SSticker.current_state > GAME_STATE_PREGAME)//Don't change the mode if the round already started. return message_admins("A vote has tried to change the gamemode, but the game has already started. Aborting.") From 3f5e68765ed1324fb02fe8f458d92c1c9f172fb8 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sun, 12 Jan 2020 03:10:42 -0800 Subject: [PATCH 10/11] am i fucking stupid? --- code/controllers/configuration/entries/game_options.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index eea5789a0e..84f0ac1f55 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -396,7 +396,6 @@ config_entry_value = TRUE /datum/config_entry/flag/modetier_voting - config_entry_value = TRUE /datum/config_entry/number/dropped_modes config_entry_value = 3 From 82d8900e5d729bb3862510caa1a1d70ba608cde1 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sun, 12 Jan 2020 03:36:47 -0800 Subject: [PATCH 11/11] aaand move this over --- code/controllers/subsystem/ticker.dm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 0948e428ff..c9562bcfd1 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -188,6 +188,12 @@ SUBSYSTEM_DEF(ticker) tipped = TRUE if(timeLeft <= 0) + if(SSvote.mode && (SSvote.mode == "roundtype" || SSvote.mode == "dynamic" || SSvote.mode == "mode tiers")) + SSvote.result() + SSpersistence.SaveSavedVotes() + for(var/client/C in SSvote.voting) + C << browse(null, "window=vote;can_close=0") + SSvote.reset() current_state = GAME_STATE_SETTING_UP Master.SetRunLevel(RUNLEVEL_SETUP) if(start_immediately) @@ -221,12 +227,6 @@ SUBSYSTEM_DEF(ticker) var/init_start = world.timeofday //Create and announce mode var/list/datum/game_mode/runnable_modes - if(SSvote.mode && (SSvote.mode == "roundtype" || SSvote.mode == "dynamic" || SSvote.mode == "mode tiers")) - SSvote.result() - SSpersistence.SaveSavedVotes() - for(var/client/C in SSvote.voting) - C << browse(null, "window=vote;can_close=0") - SSvote.reset() if(GLOB.master_mode == "random" || GLOB.master_mode == "secret") runnable_modes = config.get_runnable_modes()