PaulMartrenchar commited on
Commit
a33fe74
·
1 Parent(s): 459896f

First version of the app

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from collections import Counter
3
+
4
+ def bump_probability(drawn_card_strings, special_cards_drawn):
5
+ TOTAL_SPECIAL_CARDS = 15
6
+ special_cards_remaining = TOTAL_SPECIAL_CARDS - special_cards_drawn
7
+
8
+ # Convert strings from checkbox input to integers
9
+ drawn_cards = [int(card) for card in drawn_card_strings]
10
+
11
+ print(drawn_cards)
12
+
13
+ total_counts = {i: i for i in range(13)}
14
+ total_counts[0] = 1 # fix 0 to have 1 copy
15
+
16
+ count_drawn = Counter(drawn_cards)
17
+
18
+ bump_cards_remaining = 0
19
+ total_remaining_cards = special_cards_remaining
20
+
21
+ for card_value in range(13):
22
+ total_available = total_counts[card_value]
23
+ already_drawn = count_drawn.get(card_value, 0)
24
+ remaining = total_available - already_drawn
25
+ total_remaining_cards += remaining
26
+
27
+ if already_drawn > 0:
28
+ bump_cards_remaining += remaining
29
+
30
+ if total_remaining_cards == 0:
31
+ return "0.0% (no cards remaining)"
32
+
33
+ probability = bump_cards_remaining / total_remaining_cards
34
+ return f"{probability * 100:.2f}% chance of bumping"
35
+
36
+ # Gradio interface
37
+ card_choices = [str(i) for i in range(13)]
38
+
39
+ iface = gr.Interface(
40
+ fn=bump_probability,
41
+ inputs=[
42
+ gr.CheckboxGroup(choices=card_choices, label="Cards you have (select all drawn cards)", type="value"),
43
+ gr.Slider(minimum=0, maximum=15, step=1, label="Number of special cards drawn")
44
+ ],
45
+ outputs="text",
46
+ title="Flip 7 Bump Probability Calculator",
47
+ description="Select the number cards you've drawn and how many special cards you've already drawn to see the probability of bumping on your next card."
48
+ )
49
+
50
+ iface.launch()