elo_brain 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.overcommit.yml +5 -5
- data/.rubocop-http---relaxed-ruby-style-rubocop-yml +153 -0
- data/.rubocop.yml +65 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -2
- data/README.md +16 -4
- data/Rakefile +3 -1
- data/elo_brain.gemspec +9 -6
- data/lib/elo_brain/elo_calculations/strategies.rb +1 -1
- data/lib/elo_brain/{elos → matches}/contract.rb +1 -1
- data/lib/elo_brain/matches/match.rb +41 -0
- data/lib/elo_brain/{elos → matches}/services/launch_new_elo_calculation.rb +6 -3
- data/lib/elo_brain/{elos → matches}/types.rb +1 -1
- data/lib/elo_brain/version.rb +1 -1
- metadata +14 -10
- data/lib/elo_brain/elos/elo.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a32b22a6cbdf961ca4c101bbd3962939883667ebcc2c43a08683d73a3d2f0d66
|
4
|
+
data.tar.gz: 9d8bc552630782cda26267ce1f000f815fed06261766ed37a70d82b1ade256b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d852aff35686edde6146734b9c549215e8a7f00c2de96cab273c8b7f48c7b26d1ce751639fce39485edfcfc60afb385d2fa2ec29c604c76b8a8dbe6ff1481e06
|
7
|
+
data.tar.gz: f8bcddffd2df41f796e72b72685bc0330bb94f0a78c5e6de78e357e5136a58deb69f2de3a2c510836dc447e91762b196c79e22a55f51637128384a58cf0130af
|
data/.overcommit.yml
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
# Uncomment the following lines to make the configuration take effect.
|
17
17
|
|
18
18
|
PreCommit:
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
RuboCop:
|
20
|
+
enabled: true
|
21
|
+
command: ['bundle', 'exec', 'rubocop', '-P']
|
22
22
|
BundleOutdated:
|
23
23
|
enabled: true
|
24
24
|
BundleAudit:
|
@@ -29,6 +29,6 @@ PrePush:
|
|
29
29
|
enabled: true
|
30
30
|
command: ['bundle', 'exec', 'rspec', '-f', 'p']
|
31
31
|
quiet: false
|
32
|
-
|
33
|
-
|
32
|
+
Rubocop:
|
33
|
+
enabled: true
|
34
34
|
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# Relaxed.Ruby.Style
|
2
|
+
## Version 2.5
|
3
|
+
|
4
|
+
Style/Alias:
|
5
|
+
Enabled: false
|
6
|
+
StyleGuide: https://relaxed.ruby.style/#stylealias
|
7
|
+
|
8
|
+
Style/AsciiComments:
|
9
|
+
Enabled: false
|
10
|
+
StyleGuide: https://relaxed.ruby.style/#styleasciicomments
|
11
|
+
|
12
|
+
Style/BeginBlock:
|
13
|
+
Enabled: false
|
14
|
+
StyleGuide: https://relaxed.ruby.style/#stylebeginblock
|
15
|
+
|
16
|
+
Style/BlockDelimiters:
|
17
|
+
Enabled: false
|
18
|
+
StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
|
19
|
+
|
20
|
+
Style/CommentAnnotation:
|
21
|
+
Enabled: false
|
22
|
+
StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Enabled: false
|
26
|
+
StyleGuide: https://relaxed.ruby.style/#styledocumentation
|
27
|
+
|
28
|
+
Layout/DotPosition:
|
29
|
+
Enabled: false
|
30
|
+
StyleGuide: https://relaxed.ruby.style/#layoutdotposition
|
31
|
+
|
32
|
+
Style/DoubleNegation:
|
33
|
+
Enabled: false
|
34
|
+
StyleGuide: https://relaxed.ruby.style/#styledoublenegation
|
35
|
+
|
36
|
+
Style/EndBlock:
|
37
|
+
Enabled: false
|
38
|
+
StyleGuide: https://relaxed.ruby.style/#styleendblock
|
39
|
+
|
40
|
+
Style/FormatString:
|
41
|
+
Enabled: false
|
42
|
+
StyleGuide: https://relaxed.ruby.style/#styleformatstring
|
43
|
+
|
44
|
+
Style/IfUnlessModifier:
|
45
|
+
Enabled: false
|
46
|
+
StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
|
47
|
+
|
48
|
+
Style/Lambda:
|
49
|
+
Enabled: false
|
50
|
+
StyleGuide: https://relaxed.ruby.style/#stylelambda
|
51
|
+
|
52
|
+
Style/ModuleFunction:
|
53
|
+
Enabled: false
|
54
|
+
StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
|
55
|
+
|
56
|
+
Style/MultilineBlockChain:
|
57
|
+
Enabled: false
|
58
|
+
StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
|
59
|
+
|
60
|
+
Style/NegatedIf:
|
61
|
+
Enabled: false
|
62
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedif
|
63
|
+
|
64
|
+
Style/NegatedWhile:
|
65
|
+
Enabled: false
|
66
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
|
67
|
+
|
68
|
+
Style/NumericPredicate:
|
69
|
+
Enabled: false
|
70
|
+
StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
|
71
|
+
|
72
|
+
Style/ParallelAssignment:
|
73
|
+
Enabled: false
|
74
|
+
StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
|
75
|
+
|
76
|
+
Style/PercentLiteralDelimiters:
|
77
|
+
Enabled: false
|
78
|
+
StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
|
79
|
+
|
80
|
+
Style/PerlBackrefs:
|
81
|
+
Enabled: false
|
82
|
+
StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
|
83
|
+
|
84
|
+
Style/Semicolon:
|
85
|
+
Enabled: false
|
86
|
+
StyleGuide: https://relaxed.ruby.style/#stylesemicolon
|
87
|
+
|
88
|
+
Style/SignalException:
|
89
|
+
Enabled: false
|
90
|
+
StyleGuide: https://relaxed.ruby.style/#stylesignalexception
|
91
|
+
|
92
|
+
Style/SingleLineBlockParams:
|
93
|
+
Enabled: false
|
94
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
|
95
|
+
|
96
|
+
Style/SingleLineMethods:
|
97
|
+
Enabled: false
|
98
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
|
99
|
+
|
100
|
+
Layout/SpaceBeforeBlockBraces:
|
101
|
+
Enabled: false
|
102
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
|
103
|
+
|
104
|
+
Layout/SpaceInsideParens:
|
105
|
+
Enabled: false
|
106
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
|
107
|
+
|
108
|
+
Style/SpecialGlobalVars:
|
109
|
+
Enabled: false
|
110
|
+
StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
|
111
|
+
|
112
|
+
Style/StringLiterals:
|
113
|
+
Enabled: false
|
114
|
+
StyleGuide: https://relaxed.ruby.style/#stylestringliterals
|
115
|
+
|
116
|
+
Style/TrailingCommaInArguments:
|
117
|
+
Enabled: false
|
118
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
|
119
|
+
|
120
|
+
Style/TrailingCommaInArrayLiteral:
|
121
|
+
Enabled: false
|
122
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
|
123
|
+
|
124
|
+
Style/TrailingCommaInHashLiteral:
|
125
|
+
Enabled: false
|
126
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
|
127
|
+
|
128
|
+
Style/SymbolArray:
|
129
|
+
Enabled: false
|
130
|
+
StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
|
131
|
+
|
132
|
+
Style/WhileUntilModifier:
|
133
|
+
Enabled: false
|
134
|
+
StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
|
135
|
+
|
136
|
+
Style/WordArray:
|
137
|
+
Enabled: false
|
138
|
+
StyleGuide: https://relaxed.ruby.style/#stylewordarray
|
139
|
+
|
140
|
+
Lint/AmbiguousRegexpLiteral:
|
141
|
+
Enabled: false
|
142
|
+
StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
|
143
|
+
|
144
|
+
Lint/AssignmentInCondition:
|
145
|
+
Enabled: false
|
146
|
+
StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
|
147
|
+
|
148
|
+
Layout/LineLength:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
Metrics:
|
152
|
+
Enabled: false
|
153
|
+
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- http://relaxed.ruby.style/rubocop.yml
|
3
|
+
|
4
|
+
require:
|
5
|
+
- rubocop-performance
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
NewCops: enable
|
9
|
+
DisplayStyleGuide: true
|
10
|
+
DisplayCopNames: true
|
11
|
+
Exclude:
|
12
|
+
- "bin/*"
|
13
|
+
- "vendor/**/*"
|
14
|
+
SuggestExtensions: false
|
15
|
+
|
16
|
+
Metrics/BlockLength:
|
17
|
+
Exclude:
|
18
|
+
- "spec/**/*.rb"
|
19
|
+
- "Guardfile"
|
20
|
+
- "vendor/bundle"
|
21
|
+
- "*.gemspec"
|
22
|
+
|
23
|
+
Layout/DotPosition:
|
24
|
+
Enabled: true
|
25
|
+
EnforcedStyle: trailing
|
26
|
+
|
27
|
+
Style/Documentation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/TrailingCommaInArrayLiteral:
|
31
|
+
Enabled: true
|
32
|
+
EnforcedStyleForMultiline: comma
|
33
|
+
|
34
|
+
Style/TrailingCommaInHashLiteral:
|
35
|
+
Enabled: true
|
36
|
+
EnforcedStyleForMultiline: comma
|
37
|
+
|
38
|
+
Layout/MultilineArrayLineBreaks:
|
39
|
+
Enabled: true
|
40
|
+
|
41
|
+
Layout/MultilineHashKeyLineBreaks:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
Layout/MultilineMethodArgumentLineBreaks:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
Layout/FirstArrayElementLineBreak:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
Layout/FirstHashElementLineBreak:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Layout/FirstMethodArgumentLineBreak:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Layout/MultilineAssignmentLayout:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Layout/LineLength:
|
60
|
+
Enabled: true
|
61
|
+
Max: 120
|
62
|
+
AutoCorrect: true
|
63
|
+
Exclude:
|
64
|
+
- Gemfile
|
65
|
+
- Guardfile
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [1.1.0] - 2021-02-06
|
8
|
+
### Changed
|
9
|
+
- **BREAKING** Change entity naming : Elo => Match
|
10
|
+
- Update required ruby version : From 2.3 to 2.6
|
11
|
+
- Create changelog
|
12
|
+
|
13
|
+
[1.1.0]: https://github.com/MatthieuLPro/elo_brain/releases/tag/v1.1.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# EloBrain
|
2
|
+

|
3
|
+
[](https://travis-ci.org/MatthieuLPro/elo_brain)
|
2
4
|
|
3
|
-
|
5
|
+
This gem is an easy way to calculate new elos after a match between 2 players.
|
4
6
|
|
5
|
-
|
7
|
+
The calculation's logic is based on : [Wikipedia](https://fr.wikipedia.org/wiki/Classement_Elo#Th%C3%A9orie_math%C3%A9matique)
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -22,11 +24,21 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
First we need to create 2 players :
|
28
|
+
```ruby
|
29
|
+
player1 = EloBrain::Players::Player.from(elo: 1_200, nb_matches: 10, situation: 'winner')
|
30
|
+
player2 = EloBrain::Players::Player.from(elo: 1_400, nb_matches: 15, situation: 'looser')
|
31
|
+
```
|
32
|
+
Then we can calculate the new elo of both players by creating a match :
|
33
|
+
```ruby
|
34
|
+
match = EloBrain::Matches::Match.from(player1: player1, player2: player2)
|
35
|
+
match.calculate_new_elos # => { player1_new_elo: 1230.3898770659184, player2_new_elo: 1390.3898770659184 }
|
36
|
+
```
|
37
|
+
The result of the calculation is a <b>Hash</b>.
|
26
38
|
|
27
39
|
## Development
|
28
40
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
42
|
|
31
43
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
44
|
|
data/Rakefile
CHANGED
data/elo_brain.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/elo_brain/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -8,21 +10,22 @@ Gem::Specification.new do |spec|
|
|
8
10
|
|
9
11
|
spec.summary = "Simple elo calculation."
|
10
12
|
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
11
|
-
spec.homepage = "https://
|
13
|
+
spec.homepage = "https://rubygems.org/gems/elo_brain"
|
12
14
|
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
14
16
|
|
15
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
18
|
|
17
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
20
|
spec.metadata["source_code_uri"] = "https://github.com/MatthieuLPro/elo_brain"
|
19
|
-
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/MatthieuLPro/elo_brain/blob/master/CHANGELOG.md"
|
20
22
|
|
21
23
|
# Specify which files should be added to the gem when it is released.
|
22
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files
|
24
|
-
|
25
|
-
|
25
|
+
spec.files =
|
26
|
+
Dir.chdir(File.expand_path(__dir__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
26
29
|
spec.bindir = "exe"
|
27
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
31
|
spec.require_paths = ["lib"]
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module Matches
|
5
|
+
class Match < Dry::Struct
|
6
|
+
attribute :player1, Types::Player
|
7
|
+
attribute :player2, Types::Player
|
8
|
+
|
9
|
+
def self.from(player1:, player2:)
|
10
|
+
new(
|
11
|
+
player1: player1,
|
12
|
+
player2: player2
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.from_contract(contract:)
|
17
|
+
new(
|
18
|
+
player1: contract[:player1],
|
19
|
+
player2: contract[:player2]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def calculate_new_elos
|
24
|
+
{
|
25
|
+
player1_new_elo: EloBrain::Matches::Services::LaunchNewEloCalculation.new.call(
|
26
|
+
strategy: player1.situation,
|
27
|
+
nb_matches: player1.nb_matches,
|
28
|
+
player_elo: player1.elo,
|
29
|
+
opponent_elo: player2.elo
|
30
|
+
),
|
31
|
+
player2_new_elo: EloBrain::Matches::Services::LaunchNewEloCalculation.new.call(
|
32
|
+
strategy: player2.situation,
|
33
|
+
nb_matches: player2.nb_matches,
|
34
|
+
player_elo: player2.elo,
|
35
|
+
opponent_elo: player1.elo
|
36
|
+
),
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,14 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module EloBrain
|
4
|
-
module
|
4
|
+
module Matches
|
5
5
|
module Services
|
6
6
|
class LaunchNewEloCalculation
|
7
7
|
def call(strategy:, nb_matches:, player_elo:, opponent_elo:)
|
8
8
|
coefficient = development_coefficient(nb_matches, player_elo)
|
9
9
|
probability = win_probability(player_elo - opponent_elo)
|
10
|
-
calculation_strategy(strategy).new_elo(
|
11
|
-
|
10
|
+
calculation_strategy(strategy).new_elo(
|
11
|
+
elo: player_elo,
|
12
|
+
development_coefficient: coefficient,
|
13
|
+
win_probability: probability
|
14
|
+
)
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
data/lib/elo_brain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elo_brain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu <Malus> Lu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundle-audit
|
@@ -125,7 +125,10 @@ files:
|
|
125
125
|
- ".idea/vcs.xml"
|
126
126
|
- ".overcommit.yml"
|
127
127
|
- ".rspec"
|
128
|
+
- ".rubocop-http---relaxed-ruby-style-rubocop-yml"
|
129
|
+
- ".rubocop.yml"
|
128
130
|
- ".travis.yml"
|
131
|
+
- CHANGELOG.md
|
129
132
|
- CODE_OF_CONDUCT.md
|
130
133
|
- Gemfile
|
131
134
|
- Gemfile.lock
|
@@ -146,21 +149,22 @@ files:
|
|
146
149
|
- lib/elo_brain/elo_calculations/strategies.rb
|
147
150
|
- lib/elo_brain/elo_calculations/variation.rb
|
148
151
|
- lib/elo_brain/elo_calculations/winner.rb
|
149
|
-
- lib/elo_brain/
|
150
|
-
- lib/elo_brain/
|
151
|
-
- lib/elo_brain/
|
152
|
-
- lib/elo_brain/
|
152
|
+
- lib/elo_brain/matches/contract.rb
|
153
|
+
- lib/elo_brain/matches/match.rb
|
154
|
+
- lib/elo_brain/matches/services/launch_new_elo_calculation.rb
|
155
|
+
- lib/elo_brain/matches/types.rb
|
153
156
|
- lib/elo_brain/players/contract.rb
|
154
157
|
- lib/elo_brain/players/player.rb
|
155
158
|
- lib/elo_brain/players/types.rb
|
156
159
|
- lib/elo_brain/version.rb
|
157
160
|
- lib/elo_brain/win_probability/probability_calculation.rb
|
158
|
-
homepage: https://
|
161
|
+
homepage: https://rubygems.org/gems/elo_brain
|
159
162
|
licenses:
|
160
163
|
- MIT
|
161
164
|
metadata:
|
162
|
-
homepage_uri: https://
|
165
|
+
homepage_uri: https://rubygems.org/gems/elo_brain
|
163
166
|
source_code_uri: https://github.com/MatthieuLPro/elo_brain
|
167
|
+
changelog_uri: https://github.com/MatthieuLPro/elo_brain/blob/master/CHANGELOG.md
|
164
168
|
post_install_message:
|
165
169
|
rdoc_options: []
|
166
170
|
require_paths:
|
@@ -169,14 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
173
|
requirements:
|
170
174
|
- - ">="
|
171
175
|
- !ruby/object:Gem::Version
|
172
|
-
version: 2.
|
176
|
+
version: 2.6.0
|
173
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
178
|
requirements:
|
175
179
|
- - ">="
|
176
180
|
- !ruby/object:Gem::Version
|
177
181
|
version: '0'
|
178
182
|
requirements: []
|
179
|
-
rubygems_version: 3.0.
|
183
|
+
rubygems_version: 3.0.3
|
180
184
|
signing_key:
|
181
185
|
specification_version: 4
|
182
186
|
summary: Simple elo calculation.
|
data/lib/elo_brain/elos/elo.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module EloBrain
|
4
|
-
module Elos
|
5
|
-
class Elo < Dry::Struct
|
6
|
-
attribute :player1, Types::Player
|
7
|
-
attribute :player2, Types::Player
|
8
|
-
|
9
|
-
def self.from(player1:, player2:)
|
10
|
-
new(
|
11
|
-
player1: player1,
|
12
|
-
player2: player2
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.from_contract(contract:)
|
17
|
-
new(
|
18
|
-
player1: contract[:player1],
|
19
|
-
player2: contract[:player2]
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def calculate_new_elos
|
24
|
-
{
|
25
|
-
player1_new_elo: EloBrain::Elos::Services::LaunchNewEloCalculation.new.call(strategy: player1.situation,
|
26
|
-
nb_matches: player1.nb_matches, player_elo: player1.elo, opponent_elo: player2.elo),
|
27
|
-
player2_new_elo: EloBrain::Elos::Services::LaunchNewEloCalculation.new.call(strategy: player2.situation,
|
28
|
-
nb_matches: player2.nb_matches, player_elo: player2.elo, opponent_elo: player1.elo)
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|