Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing problem with rating change not being equal #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elo/rating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def expected
# For more information visit
# {Wikipedia}[http://en.wikipedia.org/wiki/Elo_rating_system#Mathematical_details]
def change
k_factor.to_f * ( result.to_f - expected )
(k_factor.to_f * ( result.to_i - expected )).to_i
end


Expand Down
10 changes: 10 additions & 0 deletions spec/elo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@

end

#from Wikipedia: The winner of a contest between two players gains a certain number of points in his rating and the losing player loses the same amount.
it "rating change should be the same" do
bob = Elo::Player.new :rating => 1000
jane = Elo::Player.new :rating => 1000

game1 = bob.wins_from(jane)

(1000 - jane.rating).should == (bob.rating - 1000)
end

describe "Configuration" do

it "default_rating" do
Expand Down