Class: Jeopardy::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/jeopardy.rb,
ext/jeopardy/jeopardy.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Player

Initializes a new Jeopardy::Game with an optional hash containing the following keys:

:score

The current score of the player.

:buzzer_rating

A rating from zero to infinity of how likely a player is to ring in first. When multiple players ring in, the odds of an individual player ringing in first is equal to their rating divided by the sum of the ratings. (default: 1.0)

:knowledge_rating

A rating from -1.0 to 1.0 of how likely a player is to answer correctly after ringing in. It’s a piecewise function with -1.0 ratings always answering incorrectly, 0.0 answering at the Jeopardy! average, and 1.0 always answering correctly. (default: 0.0)

:dd_fj_knowledge

The same as knowledge_rating, but pertaining to Daily Doubles/Final Jeopardy! instead of after ringing in. (default: 0.0)

:confidence_rating

How often a player attempts to ring in. -1.0 will never ring in, 0.0 rings in at an average rate, and 1.0 rings in every clue. (default: 0.0)



166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/jeopardy.rb', line 166

def initialize(options = {})
  options[:score] ||= 0
  options[:buzzer_rating] ||= 1.0
  options[:knowledge_rating] ||= 0.0
  options[:dd_fj_rating] ||= 0.0
  options[:confidence_rating] ||= 0.0

  @score = options[:score].to_i
  @buzzer_rating = options[:buzzer_rating].to_f
  @knowledge_rating = options[:knowledge_rating].to_f
  @dd_fj_rating = options[:dd_fj_rating].to_f
  @confidence_rating = options[:confidence_rating].to_f
end

Instance Attribute Details

#buzzer_ratingObject

Returns the value of attribute buzzer_rating.



155
156
157
# File 'lib/jeopardy.rb', line 155

def buzzer_rating
  @buzzer_rating
end

#confidence_ratingObject

Returns the value of attribute confidence_rating.



155
156
157
# File 'lib/jeopardy.rb', line 155

def confidence_rating
  @confidence_rating
end

#dd_fj_ratingObject

Returns the value of attribute dd_fj_rating.



155
156
157
# File 'lib/jeopardy.rb', line 155

def dd_fj_rating
  @dd_fj_rating
end

#knowledge_ratingObject

Returns the value of attribute knowledge_rating.



155
156
157
# File 'lib/jeopardy.rb', line 155

def knowledge_rating
  @knowledge_rating
end

#scoreObject

Returns the value of attribute score.



155
156
157
# File 'lib/jeopardy.rb', line 155

def score
  @score
end

Instance Method Details

#clue_odds(rb_clue) ⇒ Object

Return the decimal odds of the Player answering an ordinary clue correctly.

Usage

Jeopardy::Player.new.odds_of_answering_clue(Jeopardy::Clue.new)

#=> 0.9316826244



201
202
203
204
# File 'lib/jeopardy.rb', line 201

def clue_odds(clue)
  #empty, just used a placeholder for documentation
  #actual implementation is in jeopardy.c
end

#daily_double_odds(rb_clue) ⇒ Object

Returns the decimal odds of the Player answering a Daily Double correctly.

Usage

Jeopardy::Player.new.odds_of_answering_daily_double(Jeopardy::Clue.new)

#=> 0.76



188
189
190
191
# File 'lib/jeopardy.rb', line 188

def daily_double_odds(daily_double)
  #empty, just used a placeholder for documentation
  #actual implementation is in jeopardy.c
end

#final_jeopardy_oddsObject

Return the decimal odds of the Player answering final jeopardy correctly.

Usage

Jeopardy::Player.new.final_jeopardy_odds(Jeopardy::Clue.new)

#=> 0.9316826244



213
214
215
216
# File 'lib/jeopardy.rb', line 213

def final_jeopardy_odds()
  #empty, just used a placeholder for documentation
  #actual implementation is in jeopardy.c
end