python_data_scien/poc1/min_porj_4(Yahtzee).py
def expected_value(held_dice, num_die_sides, num_free_dice):
    """
    Compute the expected value based on held_dice given that there
    are num_free_dice to be rolled, each with num_die_sides.

    held_dice: dice that you will hold
    num_die_sides: number of sides on each die
    num_free_dice: number of dice to be rolled

    Returns a floating point expected value
    """
    all_sequences_set = gen_all_sequences(range(1,num_die_sides+1), num_free_dice)
    all_sequences_list = list(all_sequences_set)
    possible_event_list = []
    for i_tuple in all_sequences_list:
        temp_held_dice_list = list(held_dice)
        temp_held_dice_list.extend(list(i_tuple))
        possible_event_list.append(tuple(temp_held_dice_list))
    #print 'possible_event_list:',str(possible_event_list)
    score_event_list = []
    for j_tuple in possible_event_list:
        score_int = score(j_tuple)
        score_event_list.append(score_int)
    #print 'score_event_list:',str(score_event_list)
    score_event_len = len(score_event_list)
    expected_value_float = 0.0
    for k_int in sorted(list(set(score_event_list))):
        expected_value_float += k_int*score_event_list.count(k_int)/float(score_event_len)

    #print 'expected_value_float:',str(expected_value_float)
    return expected_value_float

    Compute the expected value based on held_dice given that there
    are num_free_dice to be rolled, each with num_die_sides.

    held_dice: dice that you will hold
    num_die_sides: number of sides on each die
    num_free_dice: number of dice to be rolled

    Returns a floating point expected value
    
Compute the expected value based on held_dice given that there
are num_free_dice to be rolled, each with num_die_sides.

dice that you will hold
num_die_sides: number of sides on each die
num_free_dice: number of dice to be rolled

Returns a floating point expected value
Compute the expected value based on held_dice given that there are num_free_dice to be rolled each with num_die_sides . dice that you will hold num_die_sides : number of sides on each die num_free_dice : number of dice to be rolled Returns a floating point expected value
def expected_value(held_dice, num_die_sides, num_free_dice):
    all_sequences_set = gen_all_sequences(range(1,num_die_sides+1), num_free_dice)
    all_sequences_list = list(all_sequences_set)
    possible_event_list = []
    for i_tuple in all_sequences_list:
        temp_held_dice_list = list(held_dice)
        temp_held_dice_list.extend(list(i_tuple))
        possible_event_list.append(tuple(temp_held_dice_list))
    score_event_list = []
    for j_tuple in possible_event_list:
        score_int = score(j_tuple)
        score_event_list.append(score_int)
    score_event_len = len(score_event_list)
    expected_value_float = 0.0
    for k_int in sorted(list(set(score_event_list))):
        expected_value_float += k_int*score_event_list.count(k_int)/float(score_event_len)
    return expected_value_float
def expected_value ( held_dice , num_die_sides , num_free_dice ) : all_sequences_set = gen_all_sequences ( range ( 1 , num_die_sides + 1 ) , num_free_dice ) all_sequences_list = list ( all_sequences_set ) possible_event_list = [ ] for i_tuple in all_sequences_list : temp_held_dice_list = list ( held_dice ) temp_held_dice_list . extend ( list ( i_tuple ) ) possible_event_list . append ( tuple ( temp_held_dice_list ) ) score_event_list = [ ] for j_tuple in possible_event_list : score_int = score ( j_tuple ) score_event_list . append ( score_int ) score_event_len = len ( score_event_list ) expected_value_float = 0.0 for k_int in sorted ( list ( set ( score_event_list ) ) ) : expected_value_float += k_int * score_event_list . count ( k_int ) / float ( score_event_len ) return expected_value_float
Compute the expected value based on held_dice given that there
are num_free_dice to be rolled, each with num_die_sides.
Compute the expected value based on held_dice given that there are num_free_dice to be rolled each with num_die_sides .
"""
    Compute the expected value based on held_dice given that there
    are num_free_dice to be rolled, each with num_die_sides.

    held_dice: dice that you will hold
    num_die_sides: number of sides on each die
    num_free_dice: number of dice to be rolled

    Returns a floating point expected value
    """ #print 'possible_event_list:',str(possible_event_list)
 #print 'score_event_list:',str(score_event_list)
 #print 'expected_value_float:',str(expected_value_float)

held_dice
num_die_sides
num_free_dice