import random

def roll():
    global total, wanted
    hit = 0
    for i in range(5):
        if random.random() < 0.4: #is 3 cost
            total -= 1
            if random.randint(1,total) < wanted: # hit
                wanted -= 1
                hit += 1
    return hit

wave_out = 0
not_wave_out = 0

wave = 0
not_wave = 0

for sims in range(100000):
    total = 13*18
    wanted = 18

    for i in range(7):
        wanted_out = roll()

    found = roll() + roll() + roll()
    if found > 0:
        wave += 1
        wave_out += wanted + found #how many wanted left when you in wave
    else:
        not_wave += 1
        not_wave_out += wanted #how many wanted left when you're not in wave

in_wave= wave_out/wave
no_wave = not_wave_out/not_wave
print("in wave:", in_wave, wave_out, wave)
print("no wave:", no_wave, not_wave_out, not_wave)
print("you have", in_wave-no_wave, "more copies in wave")
print("which is", str(((in_wave/no_wave)-1)*100)+"%","more chance of hitting 3 cost you wanted")