Class: Saulabs::TrueSkill::FactorGraph
- Inherits:
-
Object
- Object
- Saulabs::TrueSkill::FactorGraph
- Defined in:
- lib/saulabs/trueskill/factor_graph.rb
Instance Attribute Summary collapse
- #beta ⇒ Float readonly
- #beta_squared ⇒ Float readonly
- #draw_probability ⇒ Float readonly
- #epsilon ⇒ Float readonly
- #layers ⇒ Object readonly
- #teams ⇒ Array<Array<TrueSkill::Rating>> readonly
Instance Method Summary collapse
- #draw_margin ⇒ Object
-
#initialize(teams, ranks, options = {}) ⇒ FactorGraph
constructor
Creates a new trueskill factor graph for calculating the new skills based on the given game parameters.
-
#update_skills ⇒ Float
Updates the skills of the players inplace.
Constructor Details
#initialize(teams, ranks, options = {}) ⇒ FactorGraph
Creates a new trueskill factor graph for calculating the new skills based on the given game parameters
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 61 def initialize(teams, ranks, = {}) @teams = teams @ranks = ranks @beta = [:beta] || 25/6.0 @draw_probability = [:draw_probability] || 0.1 @beta_squared = @beta**2 @epsilon = -Math.sqrt(2.0 * @beta_squared) * Gauss::Distribution.inv_cdf((1.0 - @draw_probability) / 2.0) @prior_layer = Layers::PriorToSkills.new(self, @teams) @layers = [ @prior_layer, Layers::SkillsToPerformances.new(self), Layers::PerformancesToTeamPerformances.new(self), Layers::IteratedTeamPerformances.new(self, Layers::TeamPerformanceDifferences.new(self), Layers::TeamDifferenceComparision.new(self, ranks) ) ] end |
Instance Attribute Details
#beta ⇒ Float (readonly)
11 12 13 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 11 def beta @beta end |
#beta_squared ⇒ Float (readonly)
14 15 16 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 14 def beta_squared @beta_squared end |
#draw_probability ⇒ Float (readonly)
17 18 19 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 17 def draw_probability @draw_probability end |
#epsilon ⇒ Float (readonly)
20 21 22 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 20 def epsilon @epsilon end |
#layers ⇒ Object (readonly)
23 24 25 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 23 def layers @layers end |
#teams ⇒ Array<Array<TrueSkill::Rating>> (readonly)
8 9 10 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 8 def teams @teams end |
Instance Method Details
#draw_margin ⇒ Object
81 82 83 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 81 def draw_margin Gauss::Distribution.inv_cdf(0.5*(@draw_probability + 1)) * Math.sqrt(1 + 1) * @beta end |
#update_skills ⇒ Float
Updates the skills of the players inplace
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 88 def update_skills build_layers run_schedule @teams.each_with_index do |team, i| team.each_with_index do |player, j| player.replace(@prior_layer.output[i][j]) end end ranking_probability end |