daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import randint
  2. import sys
  3. def gacha(n):
  4.     result = {
  5.         'silver': 0,
  6.         'gold': 0,
  7.         'platinum': 0,
  8.         'black': 0
  9.     }
  10.  
  11.     black_saver = 0
  12.     platinum_saver = 0
  13.  
  14.     for _ in range(n):
  15.         dice = randint(1, 100)
  16.  
  17.         # 保底黑
  18.         if black_saver == 32:
  19.             result['black'] += 1
  20.             black_saver = 0
  21.             # 如果同时遇到双保底的话不改变白计数器
  22.             if platinum_saver != 9:
  23.                 platinum_saver += 1
  24.             continue
  25.  
  26.         # 保底白
  27.         if platinum_saver == 9:
  28.             # 如果保底白抽到黑了不改变白计数器
  29.             if 1 <= dice <= 3:
  30.                 result['black'] += 1
  31.                 black_saver = 0
  32.                 continue
  33.             else:
  34.                 result['platinum'] += 1
  35.                 platinum_saver = 0
  36.                 continue
  37.  
  38.         if 1 <= dice <= 37:
  39.             result['silver'] += 1
  40.             black_saver += 1
  41.             platinum_saver += 1
  42.         elif 38 <= dice <= 87:
  43.             result['gold'] += 1
  44.             black_saver += 1
  45.             platinum_saver += 1
  46.         elif 88 <= dice <= 97:
  47.             result['platinum'] += 1
  48.             platinum_saver = 0
  49.             black_saver += 1
  50.         else:
  51.             result['black'] += 1
  52.             black_saver = 0
  53.             platinum_saver += 1
  54.  
  55.     print('Silver: {silver}\nGold: {gold}\nPlatinum: {platinum}\nBlack: {black}'.format(**result))
  56.     print('Black rate: {}'.format(result['black'] / n))
  57.     print('Platinum rate: {}'.format(result['platinum'] / n))
  58.  
  59. if __name__ == '__main__':
  60.     gacha(int(sys.argv[1]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top