Module: Yahtzee::Probability

Defined in:
lib/probability.rb

Overview

I will need some kind of UI, Yahtzee::Probability aids in the decisions an AI will have to make based on their score card, the dice, and the probability vs possible score

Class Method Summary collapse

Class Method Details

.large_straight(dice, rolls_left) ⇒ Object



17
18
19
20
21
22
# File 'lib/probability.rb', line 17

def large_straight(dice, rolls_left)
  possibilities = dice.sort.each_cons(4).select do |a,b,c,d| 
    a+1==b && b+1==c && c+1==d
  end.flatten
  straight_possibility_from(dice, possibilities, rolls_left)
end

.small_straight(dice, rolls_left) ⇒ Object



10
11
12
13
14
15
# File 'lib/probability.rb', line 10

def small_straight(dice, rolls_left)
  possibilities = dice.sort.each_cons(3).select do |a,b,c| 
    a+1==b && b+1==c
  end.flatten
  straight_possibility_from(dice, possibilities, rolls_left)
end