Class: Jeopardy::Player
- Inherits:
-
Object
- Object
- Jeopardy::Player
- Defined in:
- lib/jeopardy.rb,
ext/jeopardy/jeopardy.c
Instance Attribute Summary collapse
-
#buzzer_rating ⇒ Object
Returns the value of attribute buzzer_rating.
-
#confidence_rating ⇒ Object
Returns the value of attribute confidence_rating.
-
#dd_fj_rating ⇒ Object
Returns the value of attribute dd_fj_rating.
-
#knowledge_rating ⇒ Object
Returns the value of attribute knowledge_rating.
-
#score ⇒ Object
Returns the value of attribute score.
Instance Method Summary collapse
-
#clue_odds(rb_clue) ⇒ Object
Return the decimal odds of the Player answering an ordinary clue correctly.
-
#daily_double_odds(rb_clue) ⇒ Object
Returns the decimal odds of the Player answering a Daily Double correctly.
-
#final_jeopardy_odds ⇒ Object
Return the decimal odds of the Player answering final jeopardy correctly.
-
#initialize(options = {}) ⇒ Player
constructor
Initializes a new Jeopardy::Game with an optional hash containing the following keys:.
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( = {}) [:score] ||= 0 [:buzzer_rating] ||= 1.0 [:knowledge_rating] ||= 0.0 [:dd_fj_rating] ||= 0.0 [:confidence_rating] ||= 0.0 @score = [:score].to_i @buzzer_rating = [:buzzer_rating].to_f @knowledge_rating = [:knowledge_rating].to_f @dd_fj_rating = [:dd_fj_rating].to_f @confidence_rating = [:confidence_rating].to_f end |
Instance Attribute Details
#buzzer_rating ⇒ Object
Returns the value of attribute buzzer_rating.
155 156 157 |
# File 'lib/jeopardy.rb', line 155 def @buzzer_rating end |
#confidence_rating ⇒ Object
Returns the value of attribute confidence_rating.
155 156 157 |
# File 'lib/jeopardy.rb', line 155 def @confidence_rating end |
#dd_fj_rating ⇒ Object
Returns the value of attribute dd_fj_rating.
155 156 157 |
# File 'lib/jeopardy.rb', line 155 def @dd_fj_rating end |
#knowledge_rating ⇒ Object
Returns the value of attribute knowledge_rating.
155 156 157 |
# File 'lib/jeopardy.rb', line 155 def @knowledge_rating end |
#score ⇒ Object
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_odds ⇒ Object
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 |