skillz 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +20 -0
- data/README.md +50 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/skillz.rb +11 -0
- data/lib/skillz/match.rb +39 -0
- data/lib/skillz/player.rb +21 -0
- data/lib/skillz/team.rb +23 -0
- data/skillz.gemspec +71 -0
- data/spec/skillz/match_spec.rb +151 -0
- data/spec/skillz/player_spec.rb +10 -0
- data/spec/skillz/team_spec.rb +4 -0
- data/spec/spec_helper.rb +7 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9668abe2cc46fea6d1be7f4d83d010b3b448db83
|
4
|
+
data.tar.gz: 7d43232d6d2350c5ec6837abd1308c4b9f56e926
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3a2d5f7ef1721ca20c7a508ecaa3de5cdd49248aba75dd625568de26dfbef4ddf6ec41593f70774aa33a8fe86ef5c795ecf8e8e0e5b1a82b8a9e533d0e01115
|
7
|
+
data.tar.gz: 3efb7706bf2a463910c45ff20948c680990928394310bffa93e7813daa876a25a4635e426a2a8dd39fe20532610f14221a8b6a4c4b9b27cb147e150211895c96
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
skillz
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p195
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 frausto
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Skillz
|
2
|
+
|
3
|
+
Skillz is a Competitive Ranking System based upon others such as [TrueSkill](http://research.microsoft.com/en-us/projects/trueskill/details.aspx) among others.
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'skillz'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install skillz
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
example
|
22
|
+
|
23
|
+
# create players where 30 is their average score
|
24
|
+
# 4 is the level of uncertainty of their skill
|
25
|
+
# and the last is how long its been since their last match
|
26
|
+
# skill_level defaults to 25, and uncertainty defaults to skill_level/3
|
27
|
+
# if no last played time is given it ignores it
|
28
|
+
|
29
|
+
p1 = Skillz::Player.new(30, 4, Time.now - 4.days)
|
30
|
+
p2 = Skillz::Player.new(30, 4, Time.now - 20.days)
|
31
|
+
p3 = Skillz::Player.new
|
32
|
+
p4 = Skillz::Player.new
|
33
|
+
|
34
|
+
# create teams with the players you want in each, and their ranking
|
35
|
+
# as the second argument
|
36
|
+
|
37
|
+
team1 = Skillz::Team.new([p1, p2], 1)
|
38
|
+
team2 = Skillz::Team.new([p3, p4], 2)
|
39
|
+
|
40
|
+
Skillz::Match.score(Skillz::Team.new([p1, p2], 1), Skillz::Team.new([p2], 2))
|
41
|
+
# players are now update with their new skill_level and uncertainty_in_skill_level
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
50
|
+
6. Feel satisfied.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "skillz"
|
18
|
+
gem.homepage = "http://github.com/frausto/skillz"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A ruby library implementing a competitive ranking system based on trueskill}
|
21
|
+
gem.description = %Q{A ruby library implementing a competitive ranking system based on trueskill and other similar systems. Built to address issues such as cheating, tournaments, team-play, matching, etc.. }
|
22
|
+
gem.email = "nrfrausto@gmail.com"
|
23
|
+
gem.authors = ["frausto"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "skillz #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/skillz.rb
ADDED
data/lib/skillz/match.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Skillz
|
2
|
+
class Match
|
3
|
+
|
4
|
+
def self.score(*teams)
|
5
|
+
#set initial values
|
6
|
+
teams.each{|t| t.uncertainty; t.skill_level}
|
7
|
+
|
8
|
+
teams.each do |team1|
|
9
|
+
omega = 0.0
|
10
|
+
delta = 0.0
|
11
|
+
teams.each do |team2|
|
12
|
+
next if team1 == team2
|
13
|
+
|
14
|
+
ciq = Math.sqrt(team1.uncertainty + team2.uncertainty + (2*Skillz::BETA*Skillz::BETA))
|
15
|
+
piq = 1.0/(1+Math.exp((team2.skill_level-team1.skill_level)/ciq))
|
16
|
+
sigsq_to_ciq = team1.uncertainty/ciq
|
17
|
+
|
18
|
+
s = 0.0
|
19
|
+
if team2.rank > team1.rank
|
20
|
+
s = 1.0
|
21
|
+
elsif team2.rank == team1.rank
|
22
|
+
s = 0.5
|
23
|
+
end
|
24
|
+
|
25
|
+
omega += sigsq_to_ciq * (s-piq)
|
26
|
+
gamma = Math.sqrt(team1.uncertainty)/ciq
|
27
|
+
delta += gamma*sigsq_to_ciq/ciq*piq*(1-piq)
|
28
|
+
end
|
29
|
+
|
30
|
+
team1.players.map do |player|
|
31
|
+
uncertainty_squared = player.uncertainty_in_skill_level**2
|
32
|
+
player.skill_level += uncertainty_squared/team1.uncertainty * omega
|
33
|
+
player.uncertainty_in_skill_level *= Math.sqrt([1 - uncertainty_squared / team1.uncertainty * delta, 0.0001].max)
|
34
|
+
player
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Skillz
|
2
|
+
class Player
|
3
|
+
|
4
|
+
attr_accessor :skill_level, :uncertainty_in_skill_level
|
5
|
+
|
6
|
+
def initialize(skill_level=nil, uncertainty=nil, last_match_time=nil)
|
7
|
+
@skill_level = skill_level || Skillz::INITIAL_SKILL_LEVEL
|
8
|
+
@uncertainty_in_skill_level = uncertainty || Skillz::UNCERTAINTY
|
9
|
+
if last_match_time
|
10
|
+
days = (Time.now - last_match_time).to_i / (24 * 60 * 60)
|
11
|
+
time_decay = 1 + -Math.exp((days * -1.0)/365)
|
12
|
+
time_decay *= [[uncertainty_in_skill_level, 4].max, 10].min
|
13
|
+
@uncertainty_in_skill_level += time_decay
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def adjusted_skill_level
|
18
|
+
@skill_level - @uncertainty_in_skill_level
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/skillz/team.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Skillz
|
2
|
+
class Team
|
3
|
+
|
4
|
+
attr_accessor :rank, :players
|
5
|
+
|
6
|
+
def initialize(players, rank=nil)
|
7
|
+
@players = players
|
8
|
+
@rank = rank if rank.present?
|
9
|
+
end
|
10
|
+
|
11
|
+
def skill_level
|
12
|
+
@score ||= @players.map(&:skill_level).sum
|
13
|
+
end
|
14
|
+
|
15
|
+
def uncertainty
|
16
|
+
@uncertainty_squared ||= begin
|
17
|
+
@players.map do |player|
|
18
|
+
player.uncertainty_in_skill_level * player.uncertainty_in_skill_level
|
19
|
+
end.sum
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/skillz.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "skillz"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["frausto"]
|
12
|
+
s.date = "2013-08-16"
|
13
|
+
s.description = "A ruby library implementing a competitive ranking system based on trueskill and other similar systems. Built to address issues such as cheating, tournaments, team-play, matching, etc.. "
|
14
|
+
s.email = "nrfrausto@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".ruby-gemset",
|
21
|
+
".ruby-version",
|
22
|
+
".travis.yml",
|
23
|
+
"Gemfile",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/skillz.rb",
|
29
|
+
"lib/skillz/match.rb",
|
30
|
+
"lib/skillz/player.rb",
|
31
|
+
"lib/skillz/team.rb",
|
32
|
+
"skillz.gemspec",
|
33
|
+
"spec/skillz/match_spec.rb",
|
34
|
+
"spec/skillz/player_spec.rb",
|
35
|
+
"spec/skillz/team_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = "http://github.com/frausto/skillz"
|
39
|
+
s.licenses = ["MIT"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = "2.0.3"
|
42
|
+
s.summary = "A ruby library implementing a competitive ranking system based on trueskill"
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 4
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
56
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
57
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
58
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
59
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
60
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
66
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
67
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
68
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Skillz::Match do
|
4
|
+
describe 'skill_level' do
|
5
|
+
it "two new players play each other" do
|
6
|
+
p1 = Skillz::Player.new
|
7
|
+
p2 = Skillz::Player.new
|
8
|
+
|
9
|
+
p1.skill_level.should == 25
|
10
|
+
p2.skill_level.should == 25
|
11
|
+
|
12
|
+
Skillz::Match.score(Skillz::Team.new([p1], 1), Skillz::Team.new([p2], 2))
|
13
|
+
|
14
|
+
p1.skill_level.round(7).should == 27.6352314
|
15
|
+
p2.skill_level.round(7).should == 22.3647686
|
16
|
+
end
|
17
|
+
|
18
|
+
it "high level loses to low level player" do
|
19
|
+
p1 = Skillz::Player.new(30)
|
20
|
+
p2 = Skillz::Player.new(10)
|
21
|
+
|
22
|
+
p1.skill_level.should == 30
|
23
|
+
p2.skill_level.should == 10
|
24
|
+
|
25
|
+
Skillz::Match.score(Skillz::Team.new([p1], 2), Skillz::Team.new([p2], 1))
|
26
|
+
|
27
|
+
p1.skill_level.round(7).should == 25.6770186
|
28
|
+
p2.skill_level.round(7).should == 14.3229814
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it "low level loses to high level player" do
|
33
|
+
p1 = Skillz::Player.new(30)
|
34
|
+
p2 = Skillz::Player.new(10)
|
35
|
+
|
36
|
+
p1.skill_level.should == 30
|
37
|
+
p2.skill_level.should == 10
|
38
|
+
|
39
|
+
Skillz::Match.score(Skillz::Team.new([p1], 1), Skillz::Team.new([p2], 2))
|
40
|
+
|
41
|
+
p1.skill_level.round(7).should == 30.9474814
|
42
|
+
p2.skill_level.round(7).should == 9.0525186
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'uncertainty_in_skill_level' do
|
47
|
+
it "one ceratin player beats uncertain player" do
|
48
|
+
p1 = Skillz::Player.new(25, 2.3)
|
49
|
+
p2 = Skillz::Player.new(25, 10)
|
50
|
+
|
51
|
+
p1.skill_level.should == 25
|
52
|
+
p2.skill_level.should == 25
|
53
|
+
p1.uncertainty_in_skill_level.should == 2.3
|
54
|
+
p2.uncertainty_in_skill_level.should == 10
|
55
|
+
|
56
|
+
Skillz::Match.score(Skillz::Team.new([p1], 1), Skillz::Team.new([p2], 2))
|
57
|
+
|
58
|
+
p1.skill_level.round(7).should == 25.2235335
|
59
|
+
p2.skill_level.round(7).should == 20.7744132
|
60
|
+
p1.uncertainty_in_skill_level.round(7).should == 2.2978876
|
61
|
+
p2.uncertainty_in_skill_level.round(7).should == 9.2146587
|
62
|
+
end
|
63
|
+
|
64
|
+
it "one unceratin player beats certain player" do
|
65
|
+
p1 = Skillz::Player.new(25, 2.3)
|
66
|
+
p2 = Skillz::Player.new(25, 10)
|
67
|
+
|
68
|
+
p1.skill_level.should == 25
|
69
|
+
p2.skill_level.should == 25
|
70
|
+
p1.uncertainty_in_skill_level.should == 2.3
|
71
|
+
p2.uncertainty_in_skill_level.should == 10
|
72
|
+
|
73
|
+
Skillz::Match.score(Skillz::Team.new([p1], 2), Skillz::Team.new([p2], 1))
|
74
|
+
|
75
|
+
p1.skill_level.round(7).should == 24.7764665
|
76
|
+
p2.skill_level.round(7).should == 29.2255868
|
77
|
+
p1.uncertainty_in_skill_level.round(7).should == 2.2978876
|
78
|
+
p2.uncertainty_in_skill_level.round(7).should == 9.2146587
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
it "uncertain high level loses to certain low level player" do
|
83
|
+
p1 = Skillz::Player.new(30, 9.9)
|
84
|
+
p2 = Skillz::Player.new(10, 3)
|
85
|
+
|
86
|
+
p1.uncertainty_in_skill_level.should == 9.9
|
87
|
+
p2.uncertainty_in_skill_level.should == 3
|
88
|
+
p1.skill_level.should == 30
|
89
|
+
p2.skill_level.should == 10
|
90
|
+
|
91
|
+
Skillz::Match.score(Skillz::Team.new([p1], 2), Skillz::Team.new([p2], 1))
|
92
|
+
|
93
|
+
p1.skill_level.round(7).should == 23.0607762
|
94
|
+
p2.skill_level.round(7).should == 10.6372106
|
95
|
+
p1.uncertainty_in_skill_level.round(7).should == 9.5156031
|
96
|
+
p2.uncertainty_in_skill_level.round(7).should == 2.9968199
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
it "uncertain high level wins against certain low level" do
|
101
|
+
p1 = Skillz::Player.new(30, 9.9)
|
102
|
+
p2 = Skillz::Player.new(10, 3)
|
103
|
+
|
104
|
+
p1.uncertainty_in_skill_level.should == 9.9
|
105
|
+
p2.uncertainty_in_skill_level.should == 3
|
106
|
+
p1.skill_level.should == 30
|
107
|
+
p2.skill_level.should == 10
|
108
|
+
|
109
|
+
Skillz::Match.score(Skillz::Team.new([p1], 1), Skillz::Team.new([p2], 2))
|
110
|
+
|
111
|
+
p1.skill_level.round(7).should == 31.2933587
|
112
|
+
p2.skill_level.round(7).should == 9.8812343
|
113
|
+
p1.uncertainty_in_skill_level.round(7).should == 9.5156031
|
114
|
+
p2.uncertainty_in_skill_level.round(7).should == 2.9968199
|
115
|
+
end
|
116
|
+
|
117
|
+
it "certain high level loses to uncertain low level player" do
|
118
|
+
p1 = Skillz::Player.new(30, 3)
|
119
|
+
p2 = Skillz::Player.new(10, 9.9)
|
120
|
+
|
121
|
+
p1.uncertainty_in_skill_level.should == 3
|
122
|
+
p2.uncertainty_in_skill_level.should == 9.9
|
123
|
+
p1.skill_level.should == 30
|
124
|
+
p2.skill_level.should == 10
|
125
|
+
|
126
|
+
Skillz::Match.score(Skillz::Team.new([p1], 2), Skillz::Team.new([p2], 1))
|
127
|
+
|
128
|
+
p1.skill_level.round(7).should == 29.3627894
|
129
|
+
p2.skill_level.round(7).should == 16.9392238
|
130
|
+
p1.uncertainty_in_skill_level.round(7).should == 2.9968199
|
131
|
+
p2.uncertainty_in_skill_level.round(7).should == 9.5156031
|
132
|
+
end
|
133
|
+
|
134
|
+
it "certain high level wins against uncertain low level player" do
|
135
|
+
p1 = Skillz::Player.new(30, 3)
|
136
|
+
p2 = Skillz::Player.new(10, 9.9)
|
137
|
+
|
138
|
+
p1.uncertainty_in_skill_level.should == 3
|
139
|
+
p2.uncertainty_in_skill_level.should == 9.9
|
140
|
+
p1.skill_level.should == 30
|
141
|
+
p2.skill_level.should == 10
|
142
|
+
|
143
|
+
Skillz::Match.score(Skillz::Team.new([p1], 1), Skillz::Team.new([p2], 2))
|
144
|
+
|
145
|
+
p1.skill_level.round(7).should == 30.1187657
|
146
|
+
p2.skill_level.round(7).should == 8.7066413
|
147
|
+
p1.uncertainty_in_skill_level.round(7).should == 2.9968199
|
148
|
+
p2.uncertainty_in_skill_level.round(7).should == 9.5156031
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Skillz::Player do
|
4
|
+
it "should increase uncertainty based on when the last match was played" do
|
5
|
+
now = Time.now
|
6
|
+
Time.stub(:now => now)
|
7
|
+
Skillz::Player.new(25, 4, now - 60.days).uncertainty_in_skill_level.round(7).should == 4.6063338
|
8
|
+
Skillz::Player.new(25, 4, now - 10.days).uncertainty_in_skill_level.round(7).should == 4.1081014
|
9
|
+
end
|
10
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skillz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- frausto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: 'A ruby library implementing a competitive ranking system based on trueskill
|
98
|
+
and other similar systems. Built to address issues such as cheating, tournaments,
|
99
|
+
team-play, matching, etc.. '
|
100
|
+
email: nrfrausto@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files:
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.md
|
106
|
+
files:
|
107
|
+
- .ruby-gemset
|
108
|
+
- .ruby-version
|
109
|
+
- .travis.yml
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- VERSION
|
115
|
+
- lib/skillz.rb
|
116
|
+
- lib/skillz/match.rb
|
117
|
+
- lib/skillz/player.rb
|
118
|
+
- lib/skillz/team.rb
|
119
|
+
- skillz.gemspec
|
120
|
+
- spec/skillz/match_spec.rb
|
121
|
+
- spec/skillz/player_spec.rb
|
122
|
+
- spec/skillz/team_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: http://github.com/frausto/skillz
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.0.3
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: A ruby library implementing a competitive ranking system based on trueskill
|
148
|
+
test_files: []
|