-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure good matchups per gender across teams
Previously, two teams would be considered "even" if one had 3 experienced males and 3 experienced females. Since males generally mark males and females mark females, this would create a lot of poor matchups on the field. With this change, team allocation prefers combinations where not only is the overall skill the same between teams, but also the amount of skill per gender.
- Loading branch information
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
KingsAndQueensHat/TeamGeneration/UnevenGenderSkillPenalty.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using KingsAndQueensHat.Model; | ||
|
||
namespace KingsAndQueensHat.TeamGeneration | ||
{ | ||
/// <summary> | ||
/// Penalise team allocations that leave some teams with a particular dominant gender | ||
/// , while others do not | ||
/// </summary> | ||
public class UnevenGenderSkillPenalty : IPenalty | ||
{ | ||
public double ScorePenalty(List<Team> teams) | ||
{ | ||
var scores = teams.Select(team => team.GenderSkills).ToList(); | ||
int result = 0; | ||
foreach (var gender in new[] { Gender.Male, Gender.Female }) | ||
{ | ||
var total = scores.Sum(s => s[gender]); | ||
var teamCount = teams.Count; | ||
var expectedTeamGenderSkill = total / teamCount; | ||
|
||
// Sum the deviations from the expected team skill | ||
result += scores.Sum(s => Math.Abs(s[gender] - expectedTeamGenderSkill)); | ||
} | ||
return result; | ||
} | ||
|
||
public double Weighting { get { return 1.0; } } | ||
} | ||
} |