Skip to content

Commit

Permalink
Change modifier to 80 for Game of Tones contest (#1010)
Browse files Browse the repository at this point in the history
* Add files via upload

* Change modifier to 70 for Game of Tones contest

Change the token penalty modifier to 70 for Contest C6 Game of Tones, NUS SA 23/24 Sem 1.

Note: In the future, proposed implementation is to have the token penalty modifier inserted in the contest voting file as a parameter at the point of upload.

* Update assessments_test.exs

* Fix incorrect denominator to 80

---------

Co-authored-by: Richard Dominick <[email protected]>
  • Loading branch information
kjw142857 and RichDom2185 authored Oct 1, 2023
1 parent 9d9e94e commit 15fbbd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/cadet/assessments/assessments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1216,11 +1216,12 @@ defmodule Cadet.Assessments do
end

# Calculate the score based on formula
# score(v,t) = v - 2^(t/50) where v is the normalized_voting_score
# score(v,t) = v - 2^(t/n) where v is the normalized_voting_score and n is the modifier
# n = 50 for C3 & C4, n = 80 for C6
# normalized_voting_score = sum_of_scores / number_of_voters / 10 * 100
defp calculate_formula_score(sum_of_scores, number_of_voters, tokens) do
normalized_voting_score = sum_of_scores / number_of_voters / 10 * 100
normalized_voting_score - :math.pow(2, min(1023.5, tokens / 50))
normalized_voting_score - :math.pow(2, min(1023.5, tokens / 80))
end

@doc """
Expand Down
3 changes: 2 additions & 1 deletion test/cadet/assessments/assessments_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1708,10 +1708,11 @@ defmodule Cadet.AssessmentsTest do
end

defp expected_top_relative_scores(top_x) do
# test with token penalty of 80
# "return 0;" in the factory has 3 token
10..0
|> Enum.to_list()
|> Enum.map(fn score -> 10 * score - :math.pow(2, 3 / 50) end)
|> Enum.map(fn score -> 10 * score - :math.pow(2, 3 / 80) end)
|> Enum.take(top_x)
end
end

0 comments on commit 15fbbd3

Please sign in to comment.