I wrote some code to try to simulate alpha packs in the video game rainbow six siege. The jist of it is that you have a 2% chace of getting one when you win a game and the chance gets higher by 2 % if you win but didnt get a pack and by 1.5% if you lost a match.
This means you'll have a bigger or lower pack rate depending on your win rate. Anyway, here's the code. The first error is at line 12 which is under the first if statement and the line starts with "roll = random.randint". Theres also errors at lines 227 and 205 which I dont get since I dont have that many lines.
import random
percent = 0.02
packs = 0
roll = 0
matches = 0
print('winrate?')
winrate = float(input())
for n in range(1000000): #I simulate 1 000 000 matches.
match = random.randint(0, 100)
if match <= winrate: #the chance of match being lower or equal to winrate is winrate %
roll = random.randint(10000, int(round(10000/percent, 0))) #if you have a 50
matches = matches + 1 #percent chance of
if roll == 10000: #getting a pack
packs = packs + 1 #thats 1/(1/50%)
roll = 0 #or 1/(1/0.5) or 1/2
percent = 0.02 #I used 10000 to
#replace decimals
if roll > 10000:
percent = percent + 0.02 #2% higher chance when winning but not getting pack
if winrate > match:
percent = percent + 0.015 #1,5% higher chance when losing
matches = matches + 1
matchesperpack = matches / packs
print('Your average matches per pack should be' + matchesperpack)
Aucun commentaire:
Enregistrer un commentaire