elo_brain 0.1.0 → 1.0.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/.git-hooks/pre_push/rubocop.rb +18 -0
- data/.overcommit.yml +34 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +116 -0
- data/elo_brain.gemspec +10 -1
- data/lib/elo_brain.rb +8 -2
- data/lib/elo_brain/development_coefficient/eligible_situation.rb +19 -0
- data/lib/elo_brain/development_coefficient/situation_coefficient.rb +23 -0
- data/lib/elo_brain/development_coefficient/situations/amateur.rb +19 -0
- data/lib/elo_brain/development_coefficient/situations/default.rb +18 -0
- data/lib/elo_brain/development_coefficient/situations/pro.rb +19 -0
- data/lib/elo_brain/development_coefficient/situations/starting.rb +19 -0
- data/lib/elo_brain/elo_calculations/looser.rb +11 -0
- data/lib/elo_brain/elo_calculations/strategies.rb +16 -0
- data/lib/elo_brain/elo_calculations/variation.rb +12 -0
- data/lib/elo_brain/elo_calculations/winner.rb +11 -0
- data/lib/elo_brain/elos/contract.rb +18 -0
- data/lib/elo_brain/elos/elo.rb +33 -0
- data/lib/elo_brain/elos/services/launch_new_elo_calculation.rb +30 -0
- data/lib/elo_brain/elos/types.rb +11 -0
- data/lib/elo_brain/players/contract.rb +25 -0
- data/lib/elo_brain/players/player.rb +27 -0
- data/lib/elo_brain/players/types.rb +9 -0
- data/lib/elo_brain/version.rb +3 -1
- data/lib/elo_brain/win_probability/probability_calculation.rb +11 -0
- metadata +123 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e3657744394997f59bff6c65d5695715b8ab1424f788d9bfffd071ff71f60df
|
4
|
+
data.tar.gz: 4e2e3f6e6e445febcdf6bbe3039bf103c289a3e7e484630065072010dc6170ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b309e48aff347e9c6ddf1b032842db19f550497ce41a2ffeaae858cc7db8736aa95a1c2009fa44e87b82237c7583b55a8877a0afc454af7b8c61a1c1e5df990d
|
7
|
+
data.tar.gz: eccc65a71e75f5e448b5d0c567a9b6fd8fc3d245ee56dc9ab404307ee34a49f6f7024306928cd8ea4c6517129942698c83832f66f9c9d16659e8150ef287b97a
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit
|
4
|
+
module Hook
|
5
|
+
module PrePush
|
6
|
+
# Runs `rubocop` on every files.
|
7
|
+
class Rubocop < Base
|
8
|
+
def run
|
9
|
+
result = execute(['rubocop', '-P'])
|
10
|
+
return :pass if result.success?
|
11
|
+
|
12
|
+
output = result.stdout + result.stderr
|
13
|
+
[:fail, output]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/.overcommit.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
15
|
+
#
|
16
|
+
# Uncomment the following lines to make the configuration take effect.
|
17
|
+
|
18
|
+
PreCommit:
|
19
|
+
# RuboCop:
|
20
|
+
# enabled: true
|
21
|
+
# command: ['bundle', 'exec', 'rubocop', '-P']
|
22
|
+
BundleOutdated:
|
23
|
+
enabled: true
|
24
|
+
BundleAudit:
|
25
|
+
enabled: true
|
26
|
+
|
27
|
+
PrePush:
|
28
|
+
RSpec:
|
29
|
+
enabled: true
|
30
|
+
command: ['bundle', 'exec', 'rspec', '-f', 'p']
|
31
|
+
quiet: false
|
32
|
+
# Rubocop:
|
33
|
+
# enabled: true
|
34
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
elo_brain (1.0.0)
|
5
|
+
dry-struct
|
6
|
+
dry-validation
|
7
|
+
zeitwerk (~> 2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.2)
|
13
|
+
bundle-audit (0.1.0)
|
14
|
+
bundler-audit
|
15
|
+
bundler-audit (0.7.0.1)
|
16
|
+
bundler (>= 1.2.0, < 3)
|
17
|
+
thor (>= 0.18, < 2)
|
18
|
+
childprocess (4.0.0)
|
19
|
+
concurrent-ruby (1.1.8)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
dry-configurable (0.12.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
dry-core (~> 0.5, >= 0.5.0)
|
24
|
+
dry-container (0.7.2)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
27
|
+
dry-core (0.5.0)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
dry-equalizer (0.3.0)
|
30
|
+
dry-inflector (0.2.0)
|
31
|
+
dry-initializer (3.0.4)
|
32
|
+
dry-logic (1.1.0)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
dry-core (~> 0.5, >= 0.5)
|
35
|
+
dry-schema (1.6.1)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
dry-configurable (~> 0.8, >= 0.8.3)
|
38
|
+
dry-core (~> 0.5, >= 0.5)
|
39
|
+
dry-initializer (~> 3.0)
|
40
|
+
dry-logic (~> 1.0)
|
41
|
+
dry-types (~> 1.5)
|
42
|
+
dry-struct (1.4.0)
|
43
|
+
dry-core (~> 0.5, >= 0.5)
|
44
|
+
dry-types (~> 1.5)
|
45
|
+
ice_nine (~> 0.11)
|
46
|
+
dry-types (1.5.0)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
dry-container (~> 0.3)
|
49
|
+
dry-core (~> 0.5, >= 0.5)
|
50
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
51
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
52
|
+
dry-validation (1.6.0)
|
53
|
+
concurrent-ruby (~> 1.0)
|
54
|
+
dry-container (~> 0.7, >= 0.7.1)
|
55
|
+
dry-core (~> 0.4)
|
56
|
+
dry-equalizer (~> 0.2)
|
57
|
+
dry-initializer (~> 3.0)
|
58
|
+
dry-schema (~> 1.5, >= 1.5.2)
|
59
|
+
ice_nine (0.11.2)
|
60
|
+
iniparse (1.5.0)
|
61
|
+
overcommit (0.57.0)
|
62
|
+
childprocess (>= 0.6.3, < 5)
|
63
|
+
iniparse (~> 1.4)
|
64
|
+
parallel (1.20.1)
|
65
|
+
parser (3.0.0.0)
|
66
|
+
ast (~> 2.4.1)
|
67
|
+
rainbow (3.0.0)
|
68
|
+
rake (12.3.3)
|
69
|
+
regexp_parser (2.0.3)
|
70
|
+
rexml (3.2.4)
|
71
|
+
rspec (3.10.0)
|
72
|
+
rspec-core (~> 3.10.0)
|
73
|
+
rspec-expectations (~> 3.10.0)
|
74
|
+
rspec-mocks (~> 3.10.0)
|
75
|
+
rspec-core (3.10.1)
|
76
|
+
rspec-support (~> 3.10.0)
|
77
|
+
rspec-expectations (3.10.1)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-mocks (3.10.2)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-support (3.10.2)
|
84
|
+
rubocop (1.9.1)
|
85
|
+
parallel (~> 1.10)
|
86
|
+
parser (>= 3.0.0.0)
|
87
|
+
rainbow (>= 2.2.2, < 4.0)
|
88
|
+
regexp_parser (>= 1.8, < 3.0)
|
89
|
+
rexml
|
90
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
91
|
+
ruby-progressbar (~> 1.7)
|
92
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
93
|
+
rubocop-ast (1.4.1)
|
94
|
+
parser (>= 2.7.1.5)
|
95
|
+
rubocop-performance (1.9.2)
|
96
|
+
rubocop (>= 0.90.0, < 2.0)
|
97
|
+
rubocop-ast (>= 0.4.0)
|
98
|
+
ruby-progressbar (1.11.0)
|
99
|
+
thor (1.1.0)
|
100
|
+
unicode-display_width (2.0.0)
|
101
|
+
zeitwerk (2.4.2)
|
102
|
+
|
103
|
+
PLATFORMS
|
104
|
+
ruby
|
105
|
+
|
106
|
+
DEPENDENCIES
|
107
|
+
bundle-audit
|
108
|
+
elo_brain!
|
109
|
+
overcommit
|
110
|
+
rake (~> 12.3.3)
|
111
|
+
rspec (~> 3.0)
|
112
|
+
rubocop (> 0.58)
|
113
|
+
rubocop-performance
|
114
|
+
|
115
|
+
BUNDLED WITH
|
116
|
+
1.17.3
|
data/elo_brain.gemspec
CHANGED
@@ -3,7 +3,7 @@ require_relative 'lib/elo_brain/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "elo_brain"
|
5
5
|
spec.version = EloBrain::VERSION
|
6
|
-
spec.authors = ["
|
6
|
+
spec.authors = ["Matthieu <Malus> Lu"]
|
7
7
|
spec.email = ["matthieu.lu.pro@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = "Simple elo calculation."
|
@@ -26,4 +26,13 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.bindir = "exe"
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundle-audit"
|
31
|
+
spec.add_development_dependency "overcommit"
|
32
|
+
spec.add_development_dependency 'rubocop', '> 0.58'
|
33
|
+
spec.add_development_dependency "rubocop-performance"
|
34
|
+
|
35
|
+
spec.add_dependency 'dry-struct'
|
36
|
+
spec.add_dependency 'dry-validation'
|
37
|
+
spec.add_dependency 'zeitwerk', '~> 2'
|
29
38
|
end
|
data/lib/elo_brain.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'dry-validation'
|
5
|
+
require 'elo_brain/version'
|
6
|
+
require 'zeitwerk'
|
7
|
+
loader = Zeitwerk::Loader.for_gem
|
8
|
+
loader.setup
|
2
9
|
|
3
10
|
module EloBrain
|
4
11
|
class Error < StandardError; end
|
5
|
-
# Your code goes here...
|
6
12
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module DevelopmentCoefficient
|
5
|
+
class EligibleSituation
|
6
|
+
def initialize(default_condition, *conditions)
|
7
|
+
@default_condition = default_condition
|
8
|
+
@conditions = conditions
|
9
|
+
end
|
10
|
+
|
11
|
+
def situation
|
12
|
+
@conditions.each do |condition|
|
13
|
+
return condition if condition.eligible?
|
14
|
+
end
|
15
|
+
@default_condition
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module DevelopmentCoefficient
|
5
|
+
class SituationCoefficient
|
6
|
+
def call(nb_matches:, elo:)
|
7
|
+
klass = EligibleSituation.new(
|
8
|
+
Situations::Default.new,
|
9
|
+
Situations::Starting.new(nb_matches: nb_matches),
|
10
|
+
Situations::Amateur.new(elo: elo),
|
11
|
+
Situations::Pro.new(elo: elo)
|
12
|
+
).situation.class
|
13
|
+
coefficient(klass)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def coefficient(klass)
|
19
|
+
klass::COEFFICIENT
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module DevelopmentCoefficient
|
5
|
+
module Situations
|
6
|
+
class Amateur
|
7
|
+
COEFFICIENT = 20
|
8
|
+
ELO_MAX = 2_400
|
9
|
+
def initialize(elo:)
|
10
|
+
@elo = elo
|
11
|
+
end
|
12
|
+
|
13
|
+
def eligible?
|
14
|
+
@elo < ELO_MAX
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The default condition is always true
|
4
|
+
# It is call at the end of the run_conditions.rb's condition method
|
5
|
+
# This class manages all player's cases which is not working
|
6
|
+
# Then run_condition.rb's condition method always return an condition object
|
7
|
+
module EloBrain
|
8
|
+
module DevelopmentCoefficient
|
9
|
+
module Situations
|
10
|
+
class Default
|
11
|
+
COEFFICIENT = 0
|
12
|
+
def eligible?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module DevelopmentCoefficient
|
5
|
+
module Situations
|
6
|
+
class Pro
|
7
|
+
COEFFICIENT = 10
|
8
|
+
ELO_MIN = 2_399
|
9
|
+
def initialize(elo:)
|
10
|
+
@elo = elo
|
11
|
+
end
|
12
|
+
|
13
|
+
def eligible?
|
14
|
+
@elo > ELO_MIN
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module DevelopmentCoefficient
|
5
|
+
module Situations
|
6
|
+
class Starting
|
7
|
+
COEFFICIENT = 40
|
8
|
+
NB_MAXIMUM_MATCHES = 30
|
9
|
+
def initialize(nb_matches:)
|
10
|
+
@nb_matches = nb_matches
|
11
|
+
end
|
12
|
+
|
13
|
+
def eligible?
|
14
|
+
@nb_matches < NB_MAXIMUM_MATCHES
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module EloCalculations
|
5
|
+
class Looser < Variation
|
6
|
+
def new_elo(elo:, development_coefficient:, win_probability:)
|
7
|
+
elo - development_coefficient * (MAX_PROBABILITY - win_probability)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module EloCalculations
|
5
|
+
class Strategies
|
6
|
+
STRATEGIES_COLLECTION = {
|
7
|
+
winner: Winner,
|
8
|
+
looser: Looser
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def call(strategy:)
|
12
|
+
STRATEGIES_COLLECTION[strategy.to_sym].new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module EloCalculations
|
5
|
+
class Winner < Variation
|
6
|
+
def new_elo(elo:, development_coefficient:, win_probability:)
|
7
|
+
elo + development_coefficient * (MAX_PROBABILITY - win_probability)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module Elos
|
5
|
+
class Contract < Dry::Validation::Contract
|
6
|
+
params do
|
7
|
+
required(:player1).value(Types::Player)
|
8
|
+
required(:player2).value(Types::Player)
|
9
|
+
end
|
10
|
+
|
11
|
+
rule(:player1, :player2) do
|
12
|
+
if values[:player1].situation == values[:player2].situation
|
13
|
+
key.failure('must have a unique different situation for players')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module Elos
|
5
|
+
module Services
|
6
|
+
class LaunchNewEloCalculation
|
7
|
+
def call(strategy:, nb_matches:, player_elo:, opponent_elo:)
|
8
|
+
coefficient = development_coefficient(nb_matches, player_elo)
|
9
|
+
probability = win_probability(player_elo - opponent_elo)
|
10
|
+
calculation_strategy(strategy).new_elo(elo: player_elo, development_coefficient: coefficient,
|
11
|
+
win_probability: probability)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def calculation_strategy(strategy)
|
17
|
+
EloBrain::EloCalculations::Strategies.new.call(strategy: strategy)
|
18
|
+
end
|
19
|
+
|
20
|
+
def development_coefficient(nb_matches, elo)
|
21
|
+
EloBrain::DevelopmentCoefficient::SituationCoefficient.new.call(nb_matches: nb_matches, elo: elo)
|
22
|
+
end
|
23
|
+
|
24
|
+
def win_probability(difference_of_elo)
|
25
|
+
EloBrain::WinProbability::ProbabilityCalculation.new.call(difference_of_elo: difference_of_elo)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module Players
|
5
|
+
class Contract < Dry::Validation::Contract
|
6
|
+
params do
|
7
|
+
required(:elo).value(:integer)
|
8
|
+
required(:nb_matches).value(:integer)
|
9
|
+
required(:situation).value(:string)
|
10
|
+
end
|
11
|
+
|
12
|
+
rule(:elo) do
|
13
|
+
key.failure('must be zero or positive') unless value.zero? || value.positive?
|
14
|
+
end
|
15
|
+
|
16
|
+
rule(:nb_matches) do
|
17
|
+
key.failure('must be zero or positive') unless value.zero? || value.positive?
|
18
|
+
end
|
19
|
+
|
20
|
+
rule(:situation) do
|
21
|
+
key.failure('must be equal to looser or winner') unless %w[looser winner].include? value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EloBrain
|
4
|
+
module Players
|
5
|
+
class Player < Dry::Struct
|
6
|
+
attribute :elo, Types::Strict::Integer
|
7
|
+
attribute :nb_matches, Types::Strict::Integer
|
8
|
+
attribute :situation, Types::Strict::String
|
9
|
+
|
10
|
+
def self.from(elo:, nb_matches:, situation:)
|
11
|
+
new(
|
12
|
+
elo: elo,
|
13
|
+
nb_matches: nb_matches,
|
14
|
+
situation: situation
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.from_contract(contract:)
|
19
|
+
new(
|
20
|
+
elo: contract[:elo],
|
21
|
+
nb_matches: contract[:nb_matches],
|
22
|
+
situation: contract[:situation]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/elo_brain/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elo_brain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.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
11
|
date: 2021-02-05 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundle-audit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: overcommit
|
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: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.58'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.58'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-performance
|
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: dry-struct
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
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: dry-validation
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: zeitwerk
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2'
|
13
111
|
description:
|
14
112
|
email:
|
15
113
|
- matthieu.lu.pro@gmail.com
|
@@ -17,6 +115,7 @@ executables: []
|
|
17
115
|
extensions: []
|
18
116
|
extra_rdoc_files: []
|
19
117
|
files:
|
118
|
+
- ".git-hooks/pre_push/rubocop.rb"
|
20
119
|
- ".gitignore"
|
21
120
|
- ".idea/.gitignore"
|
22
121
|
- ".idea/elo_brain.iml"
|
@@ -24,10 +123,12 @@ files:
|
|
24
123
|
- ".idea/misc.xml"
|
25
124
|
- ".idea/modules.xml"
|
26
125
|
- ".idea/vcs.xml"
|
126
|
+
- ".overcommit.yml"
|
27
127
|
- ".rspec"
|
28
128
|
- ".travis.yml"
|
29
129
|
- CODE_OF_CONDUCT.md
|
30
130
|
- Gemfile
|
131
|
+
- Gemfile.lock
|
31
132
|
- LICENSE.txt
|
32
133
|
- README.md
|
33
134
|
- Rakefile
|
@@ -35,7 +136,25 @@ files:
|
|
35
136
|
- bin/setup
|
36
137
|
- elo_brain.gemspec
|
37
138
|
- lib/elo_brain.rb
|
139
|
+
- lib/elo_brain/development_coefficient/eligible_situation.rb
|
140
|
+
- lib/elo_brain/development_coefficient/situation_coefficient.rb
|
141
|
+
- lib/elo_brain/development_coefficient/situations/amateur.rb
|
142
|
+
- lib/elo_brain/development_coefficient/situations/default.rb
|
143
|
+
- lib/elo_brain/development_coefficient/situations/pro.rb
|
144
|
+
- lib/elo_brain/development_coefficient/situations/starting.rb
|
145
|
+
- lib/elo_brain/elo_calculations/looser.rb
|
146
|
+
- lib/elo_brain/elo_calculations/strategies.rb
|
147
|
+
- lib/elo_brain/elo_calculations/variation.rb
|
148
|
+
- lib/elo_brain/elo_calculations/winner.rb
|
149
|
+
- lib/elo_brain/elos/contract.rb
|
150
|
+
- lib/elo_brain/elos/elo.rb
|
151
|
+
- lib/elo_brain/elos/services/launch_new_elo_calculation.rb
|
152
|
+
- lib/elo_brain/elos/types.rb
|
153
|
+
- lib/elo_brain/players/contract.rb
|
154
|
+
- lib/elo_brain/players/player.rb
|
155
|
+
- lib/elo_brain/players/types.rb
|
38
156
|
- lib/elo_brain/version.rb
|
157
|
+
- lib/elo_brain/win_probability/probability_calculation.rb
|
39
158
|
homepage: https://github.com/MatthieuLPro/elo_brain
|
40
159
|
licenses:
|
41
160
|
- MIT
|
@@ -57,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
176
|
- !ruby/object:Gem::Version
|
58
177
|
version: '0'
|
59
178
|
requirements: []
|
60
|
-
rubygems_version: 3.0.
|
179
|
+
rubygems_version: 3.0.8
|
61
180
|
signing_key:
|
62
181
|
specification_version: 4
|
63
182
|
summary: Simple elo calculation.
|