all-up-in-your-elo 0.0.2

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