elo-ratings 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/elo-ratings.gemspec +148 -0
- data/ext/bayeselo/.gitignore +4 -0
- data/ext/bayeselo/CBradleyTerry.cpp +670 -0
- data/ext/bayeselo/CBradleyTerry.h +137 -0
- data/ext/bayeselo/CCDistribution.cpp +135 -0
- data/ext/bayeselo/CCDistribution.h +44 -0
- data/ext/bayeselo/CCDistributionCUI.cpp +104 -0
- data/ext/bayeselo/CCDistributionCUI.h +38 -0
- data/ext/bayeselo/CCondensedResults.cpp +253 -0
- data/ext/bayeselo/CCondensedResults.h +64 -0
- data/ext/bayeselo/CDiscretization.h +40 -0
- data/ext/bayeselo/CDistribution.cpp +123 -0
- data/ext/bayeselo/CDistribution.h +58 -0
- data/ext/bayeselo/CDistributionCollection.cpp +34 -0
- data/ext/bayeselo/CDistributionCollection.h +29 -0
- data/ext/bayeselo/CEloRatingCUI.cpp +1046 -0
- data/ext/bayeselo/CEloRatingCUI.h +67 -0
- data/ext/bayeselo/CIndirectCompare.h +28 -0
- data/ext/bayeselo/CJointBayesian.cpp +111 -0
- data/ext/bayeselo/CJointBayesian.h +38 -0
- data/ext/bayeselo/CLUDecomposition.cpp +154 -0
- data/ext/bayeselo/CLUDecomposition.h +36 -0
- data/ext/bayeselo/CMatrix.cpp +48 -0
- data/ext/bayeselo/CMatrix.h +35 -0
- data/ext/bayeselo/CMatrixIO.cpp +27 -0
- data/ext/bayeselo/CMatrixIO.h +17 -0
- data/ext/bayeselo/CPredictionCUI.cpp +393 -0
- data/ext/bayeselo/CPredictionCUI.h +50 -0
- data/ext/bayeselo/CResultSet.cpp +245 -0
- data/ext/bayeselo/CResultSet.h +50 -0
- data/ext/bayeselo/CResultSetCUI.cpp +355 -0
- data/ext/bayeselo/CResultSetCUI.h +44 -0
- data/ext/bayeselo/CTimeIO.cpp +58 -0
- data/ext/bayeselo/CTimeIO.h +19 -0
- data/ext/bayeselo/CVector.cpp +110 -0
- data/ext/bayeselo/CVector.h +42 -0
- data/ext/bayeselo/EloDataFromFile.cpp +120 -0
- data/ext/bayeselo/EloDataFromFile.h +21 -0
- data/ext/bayeselo/README +8 -0
- data/ext/bayeselo/ReadLineToString.cpp +32 -0
- data/ext/bayeselo/ReadLineToString.h +18 -0
- data/ext/bayeselo/chtime.cpp +56 -0
- data/ext/bayeselo/chtime.h +61 -0
- data/ext/bayeselo/chtimer.h +27 -0
- data/ext/bayeselo/clktimer.cpp +178 -0
- data/ext/bayeselo/clktimer.h +29 -0
- data/ext/bayeselo/consolui.cpp +538 -0
- data/ext/bayeselo/consolui.h +154 -0
- data/ext/bayeselo/const.cpp +79 -0
- data/ext/bayeselo/const.h +42 -0
- data/ext/bayeselo/date.cpp +96 -0
- data/ext/bayeselo/date.h +44 -0
- data/ext/bayeselo/debug.h +58 -0
- data/ext/bayeselo/elomain.cpp +26 -0
- data/ext/bayeselo/extconf.rb +6 -0
- data/ext/bayeselo/list.h +367 -0
- data/ext/bayeselo/listi.h +125 -0
- data/ext/bayeselo/move.cpp +249 -0
- data/ext/bayeselo/move.h +139 -0
- data/ext/bayeselo/pgn.h +62 -0
- data/ext/bayeselo/pgnlex.cpp +432 -0
- data/ext/bayeselo/pgnlex.h +105 -0
- data/ext/bayeselo/pgnstr.cpp +126 -0
- data/ext/bayeselo/piece.h +44 -0
- data/ext/bayeselo/player.h +31 -0
- data/ext/bayeselo/position.h +89 -0
- data/ext/bayeselo/random.cpp +114 -0
- data/ext/bayeselo/random.h +63 -0
- data/ext/bayeselo/rb_bayeselo.cpp +76 -0
- data/ext/bayeselo/readstr.cpp +51 -0
- data/ext/bayeselo/readstr.h +19 -0
- data/ext/bayeselo/square.h +61 -0
- data/ext/bayeselo/str.cpp +81 -0
- data/ext/bayeselo/str.h +71 -0
- data/ext/bayeselo/version.cpp +30 -0
- data/ext/bayeselo/version.h +28 -0
- data/ext/bayeselo/version_number.h +1 -0
- data/lib/bayeselo.rb +6 -0
- data/lib/bayeselo/bayeselo.rb +11 -0
- data/lib/bayeselo/c_bayeselo.rb +7 -0
- data/test/bayeselo/test_bayeselo.rb +33 -0
- data/test/bayeselo/test_c_bayeselo.rb +84 -0
- data/test/helper.rb +18 -0
- metadata +226 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestBayeselo < Test::Unit::TestCase
|
4
|
+
context "add_game" do
|
5
|
+
should "accept the winner and loser and add a game to bayeselo" do
|
6
|
+
bayeselo = Bayeselo.new
|
7
|
+
bayeselo.add_game :winner => "a", :loser => "b"
|
8
|
+
assert_equal 1, bayeselo.count_games("a")
|
9
|
+
assert_equal 1, bayeselo.count_games("b")
|
10
|
+
end
|
11
|
+
|
12
|
+
should "record games for the same player" do
|
13
|
+
bayeselo = Bayeselo.new
|
14
|
+
bayeselo.add_game :winner => "a", :loser => "f"
|
15
|
+
bayeselo.add_game :winner => "e", :loser => "a"
|
16
|
+
bayeselo.add_game :winner => "a", :loser => "k"
|
17
|
+
assert_equal 3, bayeselo.count_games("a")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "get_elo" do
|
22
|
+
should "have exact opposite elo for two players" do
|
23
|
+
bayeselo = Bayeselo.new
|
24
|
+
bayeselo.add_game :winner => "a", :loser => "b"
|
25
|
+
assert_equal bayeselo.get_elo("b"), -bayeselo.get_elo("a")
|
26
|
+
end
|
27
|
+
|
28
|
+
should "return nil for for a player that hasn't been recorded yet" do
|
29
|
+
bayeselo = Bayeselo.new
|
30
|
+
assert_equal nil, bayeselo.get_elo("a")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestCBayeselo < Test::Unit::TestCase
|
4
|
+
context "append" do
|
5
|
+
should "add the players" do
|
6
|
+
cbayeselo = Bayeselo::CBayeselo.new
|
7
|
+
|
8
|
+
cbayeselo.append 0, 1, CBayeselo::Player2
|
9
|
+
assert_equal 2, cbayeselo.get_players
|
10
|
+
cbayeselo.append 1, 2, CBayeselo::Player2
|
11
|
+
assert_equal 3, cbayeselo.get_players
|
12
|
+
cbayeselo.append 3, 4, CBayeselo::Player2
|
13
|
+
assert_equal 5, cbayeselo.get_players
|
14
|
+
assert_equal 1, cbayeselo.count_games(0)
|
15
|
+
assert_equal 2, cbayeselo.count_games(1)
|
16
|
+
assert_equal 1, cbayeselo.count_games(3)
|
17
|
+
assert_equal 1, cbayeselo.count_games(4)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "not be global" do
|
21
|
+
cbayeselo1 = Bayeselo::CBayeselo.new
|
22
|
+
cbayeselo2 = Bayeselo::CBayeselo.new
|
23
|
+
|
24
|
+
cbayeselo1.append 0, 1, CBayeselo::Player2
|
25
|
+
assert_equal 2, cbayeselo1.get_players
|
26
|
+
cbayeselo1.append 1, 2, CBayeselo::Player2
|
27
|
+
assert_equal 3, cbayeselo1.get_players
|
28
|
+
cbayeselo1.append 3, 4, CBayeselo::Player2
|
29
|
+
assert_equal 5, cbayeselo1.get_players
|
30
|
+
assert_equal 1, cbayeselo1.count_games(0)
|
31
|
+
assert_equal 2, cbayeselo1.count_games(1)
|
32
|
+
assert_equal 1, cbayeselo1.count_games(3)
|
33
|
+
assert_equal 1, cbayeselo1.count_games(4)
|
34
|
+
|
35
|
+
assert_equal 0, cbayeselo2.get_players
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "get_elo" do
|
40
|
+
should "return the elo of two head to head players" do
|
41
|
+
# ResultSet>addplayer a
|
42
|
+
# ResultSet>addplayer b
|
43
|
+
# ResultSet>addplayer c
|
44
|
+
# ResultSet>addplayer d
|
45
|
+
# ResultSet>addresult 0 1 1
|
46
|
+
# ResultSet>addresult 2 3 1
|
47
|
+
# ResultSet>elo
|
48
|
+
# ResultSet-EloRating>mm
|
49
|
+
# 00:00:00,00
|
50
|
+
# ResultSet-EloRating>ratings
|
51
|
+
# Rank Name Elo + - games score oppo. draws
|
52
|
+
# 1 b 5 268 268 1 50% -5 100%
|
53
|
+
# 2 d 5 268 268 1 50% -5 100%
|
54
|
+
# 3 a -5 268 268 1 50% 5 100%
|
55
|
+
# 4 c -5 268 268 1 50% 5 100%
|
56
|
+
|
57
|
+
cbayeselo = Bayeselo::CBayeselo.new
|
58
|
+
cbayeselo.append 0, 1, CBayeselo::Draw
|
59
|
+
cbayeselo.append 2, 3, CBayeselo::Draw
|
60
|
+
assert_equal -5, cbayeselo.get_elo(0)
|
61
|
+
assert_equal 5, cbayeselo.get_elo(1)
|
62
|
+
assert_equal -5, cbayeselo.get_elo(2)
|
63
|
+
assert_equal 5, cbayeselo.get_elo(3)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "count_games" do
|
68
|
+
should "return the number of games a player played" do
|
69
|
+
cbayeselo = Bayeselo::CBayeselo.new
|
70
|
+
cbayeselo.append 0, 1, CBayeselo::Player2
|
71
|
+
cbayeselo.append 2, 3, CBayeselo::Player2
|
72
|
+
cbayeselo.append 2, 0, CBayeselo::Player2
|
73
|
+
cbayeselo.append 11, 12, CBayeselo::Player2
|
74
|
+
assert_equal 2, cbayeselo.count_games(0)
|
75
|
+
assert_equal 1, cbayeselo.count_games(1)
|
76
|
+
assert_equal 2, cbayeselo.count_games(2)
|
77
|
+
assert_equal 1, cbayeselo.count_games(3)
|
78
|
+
assert_equal 0, cbayeselo.count_games(10)
|
79
|
+
assert_equal 1, cbayeselo.count_games(11)
|
80
|
+
assert_equal 1, cbayeselo.count_games(12)
|
81
|
+
assert_equal 0, cbayeselo.count_games(13)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'bayeselo'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elo-ratings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- phillc
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-19 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: shoulda
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 1
|
42
|
+
- 0
|
43
|
+
- 0
|
44
|
+
version: 1.0.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 5
|
58
|
+
- 2
|
59
|
+
version: 1.5.2
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rcov
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rice
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: *id005
|
89
|
+
description: Ruby wrapper for bayeselo
|
90
|
+
email: spyyderz@gmail.com
|
91
|
+
executables: []
|
92
|
+
|
93
|
+
extensions:
|
94
|
+
- ext/bayeselo/extconf.rb
|
95
|
+
- ext/bayeselo/extconf.rb
|
96
|
+
extra_rdoc_files:
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.rdoc
|
99
|
+
files:
|
100
|
+
- .document
|
101
|
+
- Gemfile
|
102
|
+
- Gemfile.lock
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.rdoc
|
105
|
+
- Rakefile
|
106
|
+
- VERSION
|
107
|
+
- elo-ratings.gemspec
|
108
|
+
- ext/bayeselo/.gitignore
|
109
|
+
- ext/bayeselo/CBradleyTerry.cpp
|
110
|
+
- ext/bayeselo/CBradleyTerry.h
|
111
|
+
- ext/bayeselo/CCDistribution.cpp
|
112
|
+
- ext/bayeselo/CCDistribution.h
|
113
|
+
- ext/bayeselo/CCDistributionCUI.cpp
|
114
|
+
- ext/bayeselo/CCDistributionCUI.h
|
115
|
+
- ext/bayeselo/CCondensedResults.cpp
|
116
|
+
- ext/bayeselo/CCondensedResults.h
|
117
|
+
- ext/bayeselo/CDiscretization.h
|
118
|
+
- ext/bayeselo/CDistribution.cpp
|
119
|
+
- ext/bayeselo/CDistribution.h
|
120
|
+
- ext/bayeselo/CDistributionCollection.cpp
|
121
|
+
- ext/bayeselo/CDistributionCollection.h
|
122
|
+
- ext/bayeselo/CEloRatingCUI.cpp
|
123
|
+
- ext/bayeselo/CEloRatingCUI.h
|
124
|
+
- ext/bayeselo/CIndirectCompare.h
|
125
|
+
- ext/bayeselo/CJointBayesian.cpp
|
126
|
+
- ext/bayeselo/CJointBayesian.h
|
127
|
+
- ext/bayeselo/CLUDecomposition.cpp
|
128
|
+
- ext/bayeselo/CLUDecomposition.h
|
129
|
+
- ext/bayeselo/CMatrix.cpp
|
130
|
+
- ext/bayeselo/CMatrix.h
|
131
|
+
- ext/bayeselo/CMatrixIO.cpp
|
132
|
+
- ext/bayeselo/CMatrixIO.h
|
133
|
+
- ext/bayeselo/CPredictionCUI.cpp
|
134
|
+
- ext/bayeselo/CPredictionCUI.h
|
135
|
+
- ext/bayeselo/CResultSet.cpp
|
136
|
+
- ext/bayeselo/CResultSet.h
|
137
|
+
- ext/bayeselo/CResultSetCUI.cpp
|
138
|
+
- ext/bayeselo/CResultSetCUI.h
|
139
|
+
- ext/bayeselo/CTimeIO.cpp
|
140
|
+
- ext/bayeselo/CTimeIO.h
|
141
|
+
- ext/bayeselo/CVector.cpp
|
142
|
+
- ext/bayeselo/CVector.h
|
143
|
+
- ext/bayeselo/EloDataFromFile.cpp
|
144
|
+
- ext/bayeselo/EloDataFromFile.h
|
145
|
+
- ext/bayeselo/README
|
146
|
+
- ext/bayeselo/ReadLineToString.cpp
|
147
|
+
- ext/bayeselo/ReadLineToString.h
|
148
|
+
- ext/bayeselo/chtime.cpp
|
149
|
+
- ext/bayeselo/chtime.h
|
150
|
+
- ext/bayeselo/chtimer.h
|
151
|
+
- ext/bayeselo/clktimer.cpp
|
152
|
+
- ext/bayeselo/clktimer.h
|
153
|
+
- ext/bayeselo/consolui.cpp
|
154
|
+
- ext/bayeselo/consolui.h
|
155
|
+
- ext/bayeselo/const.cpp
|
156
|
+
- ext/bayeselo/const.h
|
157
|
+
- ext/bayeselo/date.cpp
|
158
|
+
- ext/bayeselo/date.h
|
159
|
+
- ext/bayeselo/debug.h
|
160
|
+
- ext/bayeselo/elomain.cpp
|
161
|
+
- ext/bayeselo/extconf.rb
|
162
|
+
- ext/bayeselo/list.h
|
163
|
+
- ext/bayeselo/listi.h
|
164
|
+
- ext/bayeselo/move.cpp
|
165
|
+
- ext/bayeselo/move.h
|
166
|
+
- ext/bayeselo/pgn.h
|
167
|
+
- ext/bayeselo/pgnlex.cpp
|
168
|
+
- ext/bayeselo/pgnlex.h
|
169
|
+
- ext/bayeselo/pgnstr.cpp
|
170
|
+
- ext/bayeselo/piece.h
|
171
|
+
- ext/bayeselo/player.h
|
172
|
+
- ext/bayeselo/position.h
|
173
|
+
- ext/bayeselo/random.cpp
|
174
|
+
- ext/bayeselo/random.h
|
175
|
+
- ext/bayeselo/rb_bayeselo.cpp
|
176
|
+
- ext/bayeselo/readstr.cpp
|
177
|
+
- ext/bayeselo/readstr.h
|
178
|
+
- ext/bayeselo/square.h
|
179
|
+
- ext/bayeselo/str.cpp
|
180
|
+
- ext/bayeselo/str.h
|
181
|
+
- ext/bayeselo/version.cpp
|
182
|
+
- ext/bayeselo/version.h
|
183
|
+
- ext/bayeselo/version_number.h
|
184
|
+
- lib/bayeselo.rb
|
185
|
+
- lib/bayeselo/bayeselo.rb
|
186
|
+
- lib/bayeselo/c_bayeselo.rb
|
187
|
+
- test/bayeselo/test_bayeselo.rb
|
188
|
+
- test/bayeselo/test_c_bayeselo.rb
|
189
|
+
- test/helper.rb
|
190
|
+
has_rdoc: true
|
191
|
+
homepage: http://github.com/phillc/elo-ratings
|
192
|
+
licenses:
|
193
|
+
- MIT
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
|
197
|
+
require_paths:
|
198
|
+
- lib
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
none: false
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
hash: 87263453
|
205
|
+
segments:
|
206
|
+
- 0
|
207
|
+
version: "0"
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
segments:
|
214
|
+
- 0
|
215
|
+
version: "0"
|
216
|
+
requirements: []
|
217
|
+
|
218
|
+
rubyforge_project:
|
219
|
+
rubygems_version: 1.3.7
|
220
|
+
signing_key:
|
221
|
+
specification_version: 3
|
222
|
+
summary: Ruby wrapper for bayeselo
|
223
|
+
test_files:
|
224
|
+
- test/bayeselo/test_bayeselo.rb
|
225
|
+
- test/bayeselo/test_c_bayeselo.rb
|
226
|
+
- test/helper.rb
|