Mas de un doble y el doble mayor al pelo
Escenario
Jugador Uno posee varios dobles pero solo el doble mayor se encuentra "al pelo" (no acompañado por otra piedra de ese número) pero el doble menor sí:
Resultado
De las 168 manos, en 105 se tomaron al menos dos dobles, y de ello 18 de las 105 (aproximadamente el 17.14%), el doble de mayor valor estaba 'al pelo'
¿Qué te parece?
Aquí te dejo la función:
player_one_doubles_analysis = []
def count_number_in_hand(hand, target_number):
"""
Counts the total occurrences of a specific number across all pieces in a player's domino hand.
"""
counter = 0
for piece in hand:
if piece[0] == target_number:
counter += 1
if piece[1] == target_number:
counter += 1
return counter
for simulation_hands in all_simulations_player_hands:
p1_hand = simulation_hands[0] # Player One's hand is always at index 0
doubles_in_hand = []
for piece in p1_hand:
if piece[0] == piece[1]:
doubles_in_hand.append(piece[0]) # Store the value of the double
analysis_result = {
'hand': p1_hand,
'doubles': doubles_in_hand,
'num_doubles': len(doubles_in_hand),
'highest_double_al_pelo': False,
'lowest_double_acompanado': False
}
if len(doubles_in_hand) >= 2:
highest_double_value = max(doubles_in_hand)
lowest_double_value = min(doubles_in_hand)
# Check if highest double is 'al pelo'
# A double is 'al pelo' if its number does not appear in any other non-double piece
# Or, more simply for a hand: if its count is exactly 2 (the double itself)
# It needs to be 'at pelo' relative to the rest of the hand.
# Count occurrences of the highest_double_value in the entire hand
count_highest_double_val = count_number_in_hand(p1_hand, highest_double_value)
if count_highest_double_val == 2: # Only the double itself contributes to the count of 2
analysis_result['highest_double_al_pelo'] = True
# Check if lowest double is 'acompañado'
# A double is 'acompañado' if its number appears in at least one other non-double piece
# Meaning its count is greater than 2
count_lowest_double_val = count_number_in_hand(p1_hand, lowest_double_value)
if count_lowest_double_val > 2:
analysis_result['lowest_double_acompanado'] = True
player_one_doubles_analysis.append(analysis_result)
# Count total occurrences of the conditions
total_highest_al_pelo = sum(1 for res in player_one_doubles_analysis if res['highest_double_al_pelo'])
total_lowest_acompanado = sum(1 for res in player_one_doubles_analysis if res['lowest_double_acompanado'])
Comments
Post a Comment