awacke1 commited on
Commit
d771b15
โ€ข
1 Parent(s): ae6b00f

Update backup-app.py

Browse files
Files changed (1) hide show
  1. backup-app.py +82 -25
backup-app.py CHANGED
@@ -12,7 +12,9 @@ player_cards = {
12
  "action_dice": "๐ŸŽฒ",
13
  "health_tokens": "โค๏ธ",
14
  "coin": "๐Ÿ’ฐ",
15
- "battle_tokens": "โš”๏ธ"
 
 
16
  },
17
  "Player 2": {
18
  "sketch": "๐Ÿ‘จ",
@@ -21,7 +23,9 @@ player_cards = {
21
  "action_dice": "๐ŸŽฒ",
22
  "health_tokens": "โค๏ธ",
23
  "coin": "๐Ÿ’ฐ",
24
- "battle_tokens": "โš”๏ธ"
 
 
25
  }
26
  }
27
 
@@ -32,6 +36,11 @@ health_problems = ["Flu", "COVID-19", "Diabetes", "Heart Disease", "Cancer"]
32
  attack_range = (1, 20)
33
  defense_range = (1, 10)
34
 
 
 
 
 
 
35
  # Create a function to play a single round of the game
36
  def play_round(player_card, health_problem):
37
  st.write(f"{player_card['sketch']} {player_card['character']} attacks {health_problem} with {player_card['action_dice']}...")
@@ -40,18 +49,37 @@ def play_round(player_card, health_problem):
40
  health_ferocity = random.randint(*attack_range)
41
  health_resistance = random.randint(*defense_range)
42
  if attack_score > health_resistance:
43
- st.write(f"{player_card['sketch']} {player_card['character']} deals {attack_score - health_resistance} damage to {health_problem}!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  else:
45
  st.write(f"{player_card['sketch']} {player_card['character']} misses the attack!")
46
  if health_ferocity > defense_score:
47
- st.write(f"{health_problem} deals {health_ferocity - defense_score} damage to {player_card['sketch']} {player_card['character']}!")
 
 
 
48
  else:
49
  st.write(f"{health_problem} fails to attack!")
50
 
 
51
  # Create a function to play multiple rounds of the game
52
  def play_game(num_games):
53
  # Initialize the game state
54
- player_scores = {player: 0 for player in player_cards}
 
55
  health_problem_scores = {problem: 0 for problem in health_problems}
56
  for i in range(num_games):
57
  # Randomly select a player and health problem
@@ -60,23 +88,36 @@ def play_game(num_games):
60
  # Play the round
61
  play_round(player_cards[player], health_problem)
62
  # Update the scores
63
- player_scores[player] += 1
64
  health_problem_scores[health_problem] += 1
65
- # Save the game state to a CSV file
66
- with open("game_state.csv", "a", newline="") as f:
67
- writer = csv.writer(f)
68
- if os.stat("game_state.csv").st_size == 0:
69
- writer.writerow(["Player", "Sketch", "Character", "Player Board", "Action Dice", "Health Tokens", "Coin", "Battle Tokens", "Score"])
70
  for player, attributes in player_cards.items():
71
- row = [player, attributes["sketch"], attributes["character"], attributes["player_board"], attributes["action_dice"], attributes["health_tokens"], attributes["coin"], attributes["battle_tokens"], player_scores[player]]
72
- writer.writerow(row)
73
- for problem in health_problems:
74
- row = [problem, health_problem_scores[problem]]
75
- writer.writerow(row)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  # Display the game results
77
  st.write("# Game Results")
78
- for player, score in player_scores.items():
79
- st.write(f"{player}: {score} wins")
80
  for problem, score in health_problem_scores.items():
81
  st.write(f"{problem}: {score} defeats")
82
  # Display a button to download the game state CSV file
@@ -95,29 +136,45 @@ def play_game(num_games):
95
  st.download_button("game_state.csv", csv_data, file_name="game_state.csv", mime="text/csv")
96
  st.write("*Note: Downloaded files are saved in your browser's default download location*")
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  def showPressRelease():
99
  st.markdown("""
100
 
101
  title: ๐Ÿค–๐Ÿง AI-RPG-Self-Play-RLML-Health-Battler-Game๐Ÿ†๐ŸŽ๐ŸŽฎ
102
  emoji: ๐Ÿ‹๏ธโ€โ™€๏ธ๐Ÿ’ช๐Ÿฅ
103
-
104
  # AI RPG Self-Play RL ML Health Battler Game Press Release
105
-
106
  ## Introduction
107
  ๐ŸŽ‰๐ŸŽฎ๐Ÿค– Attention all gamers and health enthusiasts! The ultimate weapon to battle health problems has arrived - the AI RPG Self-Play RL ML Health Battler Game! ๐Ÿค–๐ŸŽฎ๐ŸŽ‰
108
-
109
  ## Gamified Health Battles
110
  - ๐Ÿ‹๏ธโ€โ™€๏ธ๐Ÿ’ช๐Ÿฅ Sick of boring workouts and mundane health routines? Get ready to take on health problems like never before with our gamified approach. ๐ŸŽ‰๐Ÿ•น๏ธ
111
-
112
  ## Advanced AI Technology
113
  - ๐Ÿค–๐Ÿง ๐Ÿ”ฅ The AI technology behind our game is so advanced, you'll think you're battling a real-life disease! Let the personalized gameplay experience adapt to your style and keep you engaged for hours on end. ๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ”ฌ
114
-
115
  ## Healthy Competition
116
  - ๐Ÿ†๐ŸŽ๐ŸŽฎ Ready for some healthy competition? Compete against friends and other players around the world, earning rewards and achievements with our self-play reinforcement learning algorithms. ๐ŸŒŽ๐Ÿ†
117
-
118
  ## Availability
119
  - ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ“ฒ The AI RPG Self-Play RL ML Health Battler Game is now available for public open source use on all platforms, including iOS and Android devices, via the world's largest ML platform Huggingface! Download now and start fighting for your health. ๐Ÿ“ฒ๐Ÿ’ฅ
120
-
121
  ## Conclusion
122
  - Don't let health problems get the best of you - join the fight with our AI RPG Self-Play RL ML Health Battler Game! ๐ŸŽฎ๐Ÿ’ช๐Ÿฉบ
123
 
 
12
  "action_dice": "๐ŸŽฒ",
13
  "health_tokens": "โค๏ธ",
14
  "coin": "๐Ÿ’ฐ",
15
+ "battle_tokens": "โš”๏ธ",
16
+ "score": 0,
17
+ "trophy": ""
18
  },
19
  "Player 2": {
20
  "sketch": "๐Ÿ‘จ",
 
23
  "action_dice": "๐ŸŽฒ",
24
  "health_tokens": "โค๏ธ",
25
  "coin": "๐Ÿ’ฐ",
26
+ "battle_tokens": "โš”๏ธ",
27
+ "score": 0,
28
+ "trophy": ""
29
  }
30
  }
31
 
 
36
  attack_range = (1, 20)
37
  defense_range = (1, 10)
38
 
39
+ # Define the score, health tokens, and coin emoji sets
40
+ score_emojis = ["๐Ÿ”ฅ", "๐Ÿ’ฅ", "โšก๏ธ", "๐Ÿ‘Š", "๐Ÿ’ช", "๐Ÿ‹๏ธ", "๐Ÿ‘‘", "๐ŸŽ‰", "๐ŸŽŠ", "๐ŸŽ–๏ธ", "๐Ÿ…", "๐Ÿฅ‡", "๐Ÿฅˆ", "๐Ÿฅ‰"]
41
+ health_token_emojis = ["โค๏ธ", "๐Ÿ’–", "๐Ÿ’˜", "๐Ÿ’", "๐Ÿ’ž", "๐Ÿ’“", "๐Ÿ’—", "๐Ÿ’•", "๐Ÿ’Ÿ", "โฃ๏ธ", "๐Ÿฉธ", "๐Ÿงก", "๐Ÿ’›", "๐Ÿ’š", "๐Ÿ’™", "๐Ÿ’œ"]
42
+ coin_emojis = ["๐Ÿ’ฐ", "๐Ÿ’ธ", "๐Ÿ’ณ", "๐Ÿค‘", "๐Ÿ’Ž", "๐Ÿ’ท", "๐Ÿ’ต", "๐Ÿ’ฒ", "๐Ÿฆ", "๐Ÿ’น", "๐Ÿ“ˆ", "๐Ÿ“‰", "๐Ÿ’น", "๐Ÿค‘", "๐Ÿ’ฐ", "๐Ÿ’ต"]
43
+
44
  # Create a function to play a single round of the game
45
  def play_round(player_card, health_problem):
46
  st.write(f"{player_card['sketch']} {player_card['character']} attacks {health_problem} with {player_card['action_dice']}...")
 
49
  health_ferocity = random.randint(*attack_range)
50
  health_resistance = random.randint(*defense_range)
51
  if attack_score > health_resistance:
52
+ player_card["score"] += 1
53
+ score_emoji = random.choice(score_emojis)
54
+ player_card["score_emoji"] = player_card.get("score_emoji", "") + score_emoji
55
+ st.write(f"{player_card['sketch']} {player_card['character']} deals {attack_score - health_resistance} damage to {health_problem}! {score_emoji}")
56
+ player_card["health_tokens"] += 1
57
+ health_token_emoji = random.choice(health_token_emojis)
58
+ player_card["health_token_emoji"] = player_card.get("health_token_emoji", "") + health_token_emoji
59
+ #player_card["coin"] += 10
60
+
61
+ #player_card["coin"] += 10
62
+ coin_emoji = random.choice(coin_emojis)
63
+ player_card["coin_emojis"] = player_card.get("coin_emojis", "") + coin_emoji
64
+
65
+ coin_emoji = random.choice(coin_emojis)
66
+ player_card["coin_emoji"] = player_card.get("coin_emoji", "") + coin_emoji
67
  else:
68
  st.write(f"{player_card['sketch']} {player_card['character']} misses the attack!")
69
  if health_ferocity > defense_score:
70
+ player_card["health_tokens"] -= 1
71
+ health_token_emoji = random.choice(health_token_emojis)
72
+ player_card["health_token_emoji"] = player_card.get("health_token_emoji", "") + health_token_emoji
73
+ st.write(f"{health_problem} deals {health_ferocity - defense_score} damage to {player_card['sketch']} {player_card['character']}! {health_token_emoji}")
74
  else:
75
  st.write(f"{health_problem} fails to attack!")
76
 
77
+
78
  # Create a function to play multiple rounds of the game
79
  def play_game(num_games):
80
  # Initialize the game state
81
+ for player in player_cards:
82
+ player_cards[player]["health_tokens"] = 20
83
  health_problem_scores = {problem: 0 for problem in health_problems}
84
  for i in range(num_games):
85
  # Randomly select a player and health problem
 
88
  # Play the round
89
  play_round(player_cards[player], health_problem)
90
  # Update the scores
 
91
  health_problem_scores[health_problem] += 1
92
+ # Check for a player win
 
 
 
 
93
  for player, attributes in player_cards.items():
94
+ if attributes["health_tokens"] <= 0:
95
+ st.write(f"{attributes['sketch']} {attributes['character']} has lost the game!")
96
+ else:
97
+ if attributes["score"] >= num_games / 2:
98
+ st.write(f"{attributes['sketch']} {attributes['character']} has won the game!")
99
+ # Add a trophy emoji to the player card on the sidebar
100
+ if attributes["trophy"] == "":
101
+ attributes["trophy"] = "๐Ÿ†"
102
+ if st.session_state.get(player + "_win", False):
103
+ if attributes["trophy"] == "๐Ÿ†":
104
+ attributes["trophy"] = random.choice(["๐Ÿฅ‡", "๐Ÿฅˆ", "๐Ÿฅ‰"])
105
+ st.sidebar.write(f"{attributes['sketch']} {attributes['character']} {attributes['trophy']}")
106
+ # Save the game state to a CSV file
107
+ with open("game_state.csv", "a", newline="") as f:
108
+ writer = csv.writer(f)
109
+ if os.stat("game_state.csv").st_size == 0:
110
+ writer.writerow(["Player", "Sketch", "Character", "Player Board", "Action Dice", "Health Tokens", "Coin", "Battle Tokens", "Score", "Trophy"])
111
+ for player, attributes in player_cards.items():
112
+ row = [player, attributes["sketch"], attributes["character"], attributes["player_board"], attributes["action_dice"], attributes["health_tokens"], attributes["coin"], attributes["battle_tokens"], attributes["score"], attributes["trophy"]]
113
+ writer.writerow(row)
114
+ for problem in health_problems:
115
+ row = [problem, health_problem_scores[problem]]
116
+ writer.writerow(row)
117
  # Display the game results
118
  st.write("# Game Results")
119
+ for player, attributes in player_cards.items():
120
+ st.write(f"{attributes['sketch']} {attributes['character']}: {attributes['score']} successful attacks, {attributes['health_tokens']} health tokens, {attributes['coin']} coins")
121
  for problem, score in health_problem_scores.items():
122
  st.write(f"{problem}: {score} defeats")
123
  # Display a button to download the game state CSV file
 
136
  st.download_button("game_state.csv", csv_data, file_name="game_state.csv", mime="text/csv")
137
  st.write("*Note: Downloaded files are saved in your browser's default download location*")
138
 
139
+ # Define the Streamlit app
140
+ def app():
141
+ st.set_page_config(page_title="Health Care Game", page_icon="๐Ÿฅ", layout="wide")
142
+ st.title("Health Care Game")
143
+ st.sidebar.write("# Game Settings")
144
+ num_games = st.sidebar.slider("Number of games to play", 1, 100, 10)
145
+ st.sidebar.write("# Player Cards")
146
+ for player, attributes in player_cards.items():
147
+ st.sidebar.write(f"## {player}")
148
+ st.sidebar.write(f"Sketch: {attributes['sketch']}")
149
+ st.sidebar.write(f"Character: {attributes['character']}")
150
+ st.sidebar.write(f"Player Board: {attributes['player_board']}")
151
+ st.sidebar.write(f"Action Dice: {attributes['action_dice']}")
152
+ st.sidebar.write(f"Health Tokens: {attributes['health_tokens']}")
153
+ st.sidebar.write(f"Coin: {attributes['coin']}")
154
+ st.sidebar.write(f"Battle Tokens: {attributes['battle_tokens']}")
155
+ st.sidebar.write(f"Score: {attributes['score']}")
156
+ # Display a button to start the game
157
+ if st.sidebar.button("Start Game"):
158
+ # Play the game
159
+ play_game(num_games)
160
+
161
+
162
  def showPressRelease():
163
  st.markdown("""
164
 
165
  title: ๐Ÿค–๐Ÿง AI-RPG-Self-Play-RLML-Health-Battler-Game๐Ÿ†๐ŸŽ๐ŸŽฎ
166
  emoji: ๐Ÿ‹๏ธโ€โ™€๏ธ๐Ÿ’ช๐Ÿฅ
 
167
  # AI RPG Self-Play RL ML Health Battler Game Press Release
 
168
  ## Introduction
169
  ๐ŸŽ‰๐ŸŽฎ๐Ÿค– Attention all gamers and health enthusiasts! The ultimate weapon to battle health problems has arrived - the AI RPG Self-Play RL ML Health Battler Game! ๐Ÿค–๐ŸŽฎ๐ŸŽ‰
 
170
  ## Gamified Health Battles
171
  - ๐Ÿ‹๏ธโ€โ™€๏ธ๐Ÿ’ช๐Ÿฅ Sick of boring workouts and mundane health routines? Get ready to take on health problems like never before with our gamified approach. ๐ŸŽ‰๐Ÿ•น๏ธ
 
172
  ## Advanced AI Technology
173
  - ๐Ÿค–๐Ÿง ๐Ÿ”ฅ The AI technology behind our game is so advanced, you'll think you're battling a real-life disease! Let the personalized gameplay experience adapt to your style and keep you engaged for hours on end. ๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ”ฌ
 
174
  ## Healthy Competition
175
  - ๐Ÿ†๐ŸŽ๐ŸŽฎ Ready for some healthy competition? Compete against friends and other players around the world, earning rewards and achievements with our self-play reinforcement learning algorithms. ๐ŸŒŽ๐Ÿ†
 
176
  ## Availability
177
  - ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ“ฒ The AI RPG Self-Play RL ML Health Battler Game is now available for public open source use on all platforms, including iOS and Android devices, via the world's largest ML platform Huggingface! Download now and start fighting for your health. ๐Ÿ“ฒ๐Ÿ’ฅ
 
178
  ## Conclusion
179
  - Don't let health problems get the best of you - join the fight with our AI RPG Self-Play RL ML Health Battler Game! ๐ŸŽฎ๐Ÿ’ช๐Ÿฉบ
180