Class: ScoreCalculator
- Inherits:
-
Object
- Object
- ScoreCalculator
- Defined in:
- lib/threesmodel/score_calculator.rb
Overview
This class is responsible for calculating the score for a given game board.
Constant Summary collapse
- @@score_table =
{0 => 0, 1 => 0, 2 => 0, 3 => 3, 6 => 9, 12 => 27, 24 => 81, 48 => 243, 96 => 729, 192 => 2187, 384 => 6561, 768 => 19683, 1536 => 59049, 3072 => 177147, 6144 => 531441}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.score_for(game_board) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/threesmodel/score_calculator.rb', line 17 def self.score_for(game_board) score = 0 game_board.row_vectors.each {|vector| vector.to_a.each {|val| score = score + @@score_table[val] } } score end |
Instance Method Details
#score_for(game_board) ⇒ Object
27 28 29 |
# File 'lib/threesmodel/score_calculator.rb', line 27 def score_for(game_board) ScoreCalculator.score_for(game_board) end |