Module: Zheng::Parameters

Defined in:
lib/zheng/parameters.rb

Constant Summary collapse

E =

These values are taken from the European Go Rating. See gemma.ujf.cas.cz/~cieply/GO/gor.html

0.014

Class Method Summary collapse

Class Method Details

.A(rating) ⇒ Object



6
7
8
9
# File 'lib/zheng/parameters.rb', line 6

def A rating
  return 70 if rating >= 2700
  return rating * (-1.0/20) + (205)
end

.Con(rating) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zheng/parameters.rb', line 10

def Con rating
  return 10 if rating > 2700
  return 116 if rating < 100
  parts = [ { :from => 100, :to => 200, :p => -6.0/100, :d => 122 },
            { :from => 200, :to => 1300, :p => -5.0/100, :d => 120 },
            { :from => 1300, :to => 2000, :p => -4.0/100, :d => 107 },
            { :from => 2000, :to => 2400, :p => -3.0/100, :d => 87 },
            { :from => 2400, :to => 2600, :p => -2.0/100, :d => 63 },
            { :from => 2600, :to => 2700, :p => -1.0/100, :d => 37 } ]
  parts.each do |f|
    return f[:p] * rating + f[:d] if rating >= f[:from] && rating <= f[:to]
  end
end

.expected(ratingA, ratingB) ⇒ Object



24
25
26
27
# File 'lib/zheng/parameters.rb', line 24

def expected ratingA, ratingB
  return (1 - E) - expected(ratingB, ratingA) if ratingA > ratingB
  return 1.0 / (Math::E ** ((ratingB - ratingA) / A(ratingA)) + 1)
end