class Ventiuna::Strategy
Public Instance Methods
decision(dealers_card, players_hand, can_split)
click to toggle source
# File lib/ventiuna/strategies/strategy.rb, line 7 def decision(dealers_card, players_hand, can_split) best_score(dealers_card, players_hand, can_split) end
Private Instance Methods
best_score(dealers_card, players_hand, can_split)
click to toggle source
# File lib/ventiuna/strategies/strategy.rb, line 12 def best_score(dealers_card, players_hand, can_split) r = nil best_move = nil past_moves = self.moves.where(:dealers_card_value => dealers_card.value, :hand => players_hand.to_db) #puts past_moves.inspect #past_decisions = past_moves.collect{ |m| m.decision } #return nil unless past_decisions.include?("h") && past_decisions.include?("s") past_moves.each do |m| best_move = m unless best_move next if m.decision == "sp" && !can_split # can't split here best_move = m if m.score > best_move.score end r = best_move.decision if best_move r end