Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- doors_n = 3 #сколько всего дверей
- num = 100000 #количество попыток
- change = True #менять ли дверь
- open_one = True #открывается ли лишь одна дверь перед предложением смены или же все кроме выбранной и еще одной случайной
- interact = False #выбери дверь сам
- prin = False #выводить ли дополнительную информацию
- def doors_map():
- doors = []
- bounty = random.randint(0,doors_n-1)
- for i in range(doors_n):
- if i != bounty:
- doors.append(False)
- else:
- doors.append(True)
- return doors
- def del_door(a):
- for i in range(len(a)):
- if i != choice and a[i] != True:
- if a.count(False) != 1:
- a[i] = 'hui'
- if open_one:
- break
- else:
- a[i] = False
- break
- return a
- counter = 0
- for i in range(num):
- blind = []
- for e in range(doors_n):
- blind.append('hui')
- a = doors_map()
- if interact:
- choice = input()
- else:
- choice = random.randint(0,len(a)-1)
- blind[choice] = 'CHOICE'
- if prin: print(blind)
- a = del_door(a)
- for e in range(doors_n):
- if a[e] == 'hui':
- blind[e] = False
- blind[choice] = 'CHOICE'
- if prin: print(blind)
- if change:
- blind[choice] = 'hui'
- val_list = []
- for i in range(len(a)):
- if (a[i] == False or a[i] == True) and i != choice:
- val_list.append(i)
- if interact:
- choice = input()
- else:
- choice = random.choice(val_list)
- blind[choice] = 'CHOICE'
- if prin: print(blind)
- if a[choice] == True:
- counter += 1
- if prin: print(a,'u win' if choice else 'u lose')
- print('\n\n\n\n\n\n', 'Winning rate: ', counter/num)
- #for i in range(num):
- # temp = random.randint(0,doors_n-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement