Class: WordleDecoder::WordPosition
- Inherits:
-
Object
- Object
- WordleDecoder::WordPosition
- Defined in:
- lib/wordle_decoder/word_position.rb
Defined Under Namespace
Classes: LetterPosition
Constant Summary collapse
- EMOJI_HINT_CHARS =
{ "⬛" => "b", "⬜" => "b", "🟨" => "y", "🟦" => "y", "🟩" => "g", "🟧" => "g" }.freeze
- BASE_INCONFIDENCE =
0.05
Instance Attribute Summary collapse
-
#answer_chars ⇒ Object
readonly
Returns the value of attribute answer_chars.
-
#hint_chars ⇒ Object
readonly
Returns the value of attribute hint_chars.
-
#letter_positions ⇒ Object
readonly
Returns the value of attribute letter_positions.
-
#line_index ⇒ Object
readonly
Returns the value of attribute line_index.
Instance Method Summary collapse
- #black_letter_positions ⇒ Object
- #confidence_score ⇒ Object
- #frequent_potential_words ⇒ Object
- #green_letter_positions ⇒ Object
-
#initialize(hint_line, line_index, answer_chars) ⇒ WordPosition
constructor
A new instance of WordPosition.
- #potential_words ⇒ Object
- #yellow_letter_positions ⇒ Object
Constructor Details
#initialize(hint_line, line_index, answer_chars) ⇒ WordPosition
12 13 14 15 16 17 |
# File 'lib/wordle_decoder/word_position.rb', line 12 def initialize(hint_line, line_index, answer_chars) @hint_chars = normalize_hint_chars(hint_line) @answer_chars = answer_chars @line_index = line_index @letter_positions = initialize_letter_positions(@hint_chars, @answer_chars) end |
Instance Attribute Details
#answer_chars ⇒ Object (readonly)
Returns the value of attribute answer_chars.
19 20 21 |
# File 'lib/wordle_decoder/word_position.rb', line 19 def answer_chars @answer_chars end |
#hint_chars ⇒ Object (readonly)
Returns the value of attribute hint_chars.
19 20 21 |
# File 'lib/wordle_decoder/word_position.rb', line 19 def hint_chars @hint_chars end |
#letter_positions ⇒ Object (readonly)
Returns the value of attribute letter_positions.
19 20 21 |
# File 'lib/wordle_decoder/word_position.rb', line 19 def letter_positions @letter_positions end |
#line_index ⇒ Object (readonly)
Returns the value of attribute line_index.
19 20 21 |
# File 'lib/wordle_decoder/word_position.rb', line 19 def line_index @line_index end |
Instance Method Details
#black_letter_positions ⇒ Object
49 50 51 |
# File 'lib/wordle_decoder/word_position.rb', line 49 def black_letter_positions @black_letter_positions ||= select_letter_positions_by_hint("b") end |
#confidence_score ⇒ Object
34 35 36 37 38 39 |
# File 'lib/wordle_decoder/word_position.rb', line 34 def confidence_score return 1 if potential_words.empty? score = (100 * (1.0 / potential_words.count.to_f)) (score - (score * BASE_INCONFIDENCE)).round end |
#frequent_potential_words ⇒ Object
28 29 30 |
# File 'lib/wordle_decoder/word_position.rb', line 28 def frequent_potential_words @frequent_potential_words ||= find_10_frequent_potential_words end |
#green_letter_positions ⇒ Object
41 42 43 |
# File 'lib/wordle_decoder/word_position.rb', line 41 def green_letter_positions @green_letter_positions ||= select_letter_positions_by_hint("g") end |
#potential_words ⇒ Object
24 25 26 |
# File 'lib/wordle_decoder/word_position.rb', line 24 def potential_words @potential_words ||= initialize_potential_words end |
#yellow_letter_positions ⇒ Object
45 46 47 |
# File 'lib/wordle_decoder/word_position.rb', line 45 def yellow_letter_positions @yellow_letter_positions ||= select_letter_positions_by_hint("y") end |