Salir al pelo y compañero sin ninguna piedra de ese palo
Escenario
Esta simulación se describe así:
Jugador uno sale con un doble (X:X) y su compañero no tiene ninguna piedra con el palo X
Resultados
Luego de correr lo anterior 168 veces en el simulador, la posibilidad de que ocurra que J1 salga con X:X y su compañero no tenga ninguna piedra del palo X ocurrió 5 veces lo que corresponde a 2,97%
Código python
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
def has_double_in_hand(hand, target_number):
"""
Checks if the double piece (target_number, target_number) is present in the hand.
"""
return (target_number, target_number) in hand
scenario_counts_per_number = {}
# Iterate through each number (N) from 0 to 6
for target_num_N in range(7):
count_specific_scenario = 0
# Iterate through each simulation
for simulation_hands in all_simulations_player_hands:
p1_hand = simulation_hands[0] # Player One's hand
p3_hand = simulation_hands[2] # Player Three's hand
# Condition 1: Player One has the double tile (N,N)
p1_has_double_N = has_double_in_hand(p1_hand, target_num_N)
# Condition 2: Player One's double (N,N) is 'al pelo' (total count of N in P1's hand is exactly 2)
p1_double_N_is_al_pelo = (count_number_in_hand(p1_hand, target_num_N) == 2)
# Condition 3: Player Three does NOT have any tile with the number N
p3_has_no_N = (count_number_in_hand(p3_hand, target_num_N) == 0)
# Check if all conditions are met simultaneously
if p1_has_double_N and p1_double_N_is_al_pelo and p3_has_no_N:
count_specific_scenario += 1
scenario_counts_per_number[target_num_N] = count_specific_scenario
print("Conteo de ocurrencias del escenario específico (J1 tiene doble N 'al pelo' y J3 no tiene N) para cada número N:")
for num, count in scenario_counts_per_number.items():
print(f" Número {num}: {count} veces")
total_global_scenario_count = sum(scenario_counts_per_number.values())
print(f"\nConteo total global del escenario específico (sumando todos los números N): {total_global_scenario_count} veces")
Comments
Post a Comment