Skip to content

Instantly share code, notes, and snippets.

@amaotone
Last active October 1, 2016 08:38
Show Gist options
  • Select an option

  • Save amaotone/d4f785c9d356a6bc5d5dab89b2eb9cfa to your computer and use it in GitHub Desktop.

Select an option

Save amaotone/d4f785c9d356a6bc5d5dab89b2eb9cfa to your computer and use it in GitHub Desktop.
絶対に龍巫女引く
import numpy as np
INIT_HAND = 3
INIT_DECK = 40
def probability(deck):
return np.array([(deck-i)/deck for i in range(1, INIT_HAND+1)])
def main():
p = np.array([1., 1., 1.])
# mulligan
for i in range(INIT_HAND):
p *= probability(INIT_DECK-i)
# game start
for i in range(INIT_DECK):
p *= probability(INIT_DECK-i)
turn = max(0, i+1-INIT_HAND)
if turn:
print("{0:>2}T {1[0]:.3f} {1[1]:.3f} {1[2]:.3f}".format(turn, 1-p))
if __name__ == '__main__':
main()
@amaotone
Copy link
Author

amaotone commented Oct 1, 2016

実行結果

 1T 0.168 0.310 0.432
 2T 0.191 0.349 0.479
 3T 0.214 0.386 0.524
 4T 0.237 0.422 0.566
 5T 0.260 0.457 0.605
 6T 0.283 0.491 0.642
 7T 0.306 0.524 0.677
 8T 0.329 0.556 0.709
 9T 0.352 0.586 0.739
10T 0.376 0.616 0.767
11T 0.399 0.644 0.793
12T 0.422 0.672 0.817
13T 0.445 0.698 0.839
14T 0.468 0.723 0.859
15T 0.491 0.747 0.877
16T 0.514 0.770 0.894
17T 0.537 0.792 0.909
18T 0.561 0.813 0.923
19T 0.584 0.833 0.935
20T 0.607 0.851 0.946
21T 0.630 0.869 0.955
22T 0.653 0.885 0.964
23T 0.676 0.900 0.971
24T 0.699 0.915 0.977
25T 0.722 0.928 0.982
26T 0.746 0.940 0.987
27T 0.769 0.951 0.990
28T 0.792 0.961 0.993
29T 0.815 0.969 0.996
30T 0.838 0.977 0.997
31T 0.861 0.984 0.998
32T 0.884 0.989 0.999
33T 0.907 0.993 1.000
34T 0.931 0.997 1.000
35T 0.954 0.999 1.000
36T 0.977 1.000 1.000
37T 1.000 1.000 1.000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment