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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 60 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)
10 11 12 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 10 def beta @beta end |
#beta_squared ⇒ Float (readonly)
13 14 15 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 13 def beta_squared @beta_squared end |
#draw_probability ⇒ Float (readonly)
16 17 18 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 16 def draw_probability @draw_probability end |
#epsilon ⇒ Float (readonly)
19 20 21 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 19 def epsilon @epsilon end |
#layers ⇒ Object (readonly)
22 23 24 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 22 def layers @layers end |
#teams ⇒ Array<Array<TrueSkill::Rating>> (readonly)
7 8 9 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 7 def teams @teams end |
Instance Method Details
#draw_margin ⇒ Object
80 81 82 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 80 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
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/saulabs/trueskill/factor_graph.rb', line 87 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 |