import random

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

wave_chances = 0
not_wave_chances = 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_chances += (wanted+found)/(total+found)
        wave += 1
    else:
        not_wave_chances += wanted/total
        not_wave += 1

print("in wave:", 100*wave_chances/wave, "%")
print("no wave:", 100*not_wave_chances/not_wave, "%")