awacke1 commited on
Commit
46f7263
Β·
1 Parent(s): 3711164

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -165
README.md CHANGED
@@ -8,171 +8,6 @@ pinned: false
8
  ---
9
 
10
 
11
- # Original:
12
-
13
- ```
14
- import streamlit as st
15
- import random
16
- import pandas as pd
17
- import os
18
-
19
- # Cascadia Game Components
20
- habitat_tiles = ['🌲', '🏞️', '🌊', '🌡', 'πŸŒ„']
21
- wildlife_tokens = ['🐻', 'πŸ¦…', '🐟', '🦌', '🐿️']
22
- players = ['Player 1', 'Player 2']
23
- save_file = 'cascadia_game_state.csv'
24
-
25
- # Function to load game state from CSV
26
- def load_game_state():
27
- if os.path.exists(save_file):
28
- df = pd.read_csv(save_file)
29
- game_state = {
30
- 'habitat_stack': df['habitat_stack'].dropna().tolist(),
31
- 'wildlife_stack': df['wildlife_stack'].dropna().tolist(),
32
- 'players': {}
33
- }
34
- for player in players:
35
- game_state['players'][player] = {
36
- 'habitat': df[player + '_habitat'].dropna().tolist(),
37
- 'wildlife': df[player + '_wildlife'].dropna().tolist(),
38
- 'nature_tokens': int(df[player + '_nature_tokens'][0])
39
- }
40
- return game_state
41
- else:
42
- return None
43
-
44
- # Function to save game state to CSV
45
- def save_game_state(game_state):
46
- data = {
47
- 'habitat_stack': pd.Series(game_state['habitat_stack']),
48
- 'wildlife_stack': pd.Series(game_state['wildlife_stack'])
49
- }
50
- for player in players:
51
- player_state = game_state['players'][player]
52
- data[player + '_habitat'] = pd.Series(player_state['habitat'])
53
- data[player + '_wildlife'] = pd.Series(player_state['wildlife'])
54
- data[player + '_nature_tokens'] = pd.Series([player_state['nature_tokens']])
55
- df = pd.DataFrame(data)
56
- df.to_csv(save_file, index=False)
57
-
58
- # Initialize or load game state
59
- game_state = load_game_state()
60
- if game_state is None:
61
- game_state = {
62
- 'habitat_stack': random.sample(habitat_tiles * 10, 50),
63
- 'wildlife_stack': random.sample(wildlife_tokens * 10, 50),
64
- 'players': {player: {'habitat': [], 'wildlife': [], 'nature_tokens': 3} for player in players}
65
- }
66
- save_game_state(game_state)
67
-
68
- # Streamlit Interface
69
- st.title("🌲 Cascadia Lite 🌲")
70
-
71
- # Function to draw habitat and wildlife
72
- def draw_habitat_and_wildlife(player, game_state):
73
- habitat = game_state['habitat_stack'].pop()
74
- wildlife = game_state['wildlife_stack'].pop()
75
- game_state['players'][player]['habitat'].append(habitat)
76
- game_state['players'][player]['wildlife'].append(wildlife)
77
- save_game_state(game_state)
78
-
79
-
80
- # Display players' areas and handle actions
81
- col1, col2 = st.columns(2)
82
- for index, player in enumerate(players):
83
- with (col1 if index == 0 else col2):
84
- st.write(f"## {player}'s Play Area")
85
- player_data = pd.DataFrame({
86
- 'Habitat Tiles': game_state['players'][player]['habitat'],
87
- 'Wildlife Tokens': game_state['players'][player]['wildlife']
88
- })
89
- st.dataframe(player_data)
90
-
91
- # Drafting Phase
92
- if st.button(f"{player}: Draw Habitat and Wildlife"):
93
- draw_habitat_and_wildlife(player, game_state)
94
- game_state = load_game_state()
95
-
96
- # Tile and Wildlife Placement
97
- placement_options = ['Place Habitat', 'Place Wildlife', 'Skip']
98
- placement_choice = st.selectbox(f"{player}: Choose an action", placement_options, key=f'placement_{player}')
99
- if placement_choice != 'Skip':
100
- st.write(f"{player} chose to {placement_choice}")
101
-
102
- # Nature Tokens
103
- nature_tokens = game_state['players'][player]['nature_tokens']
104
- if st.button(f"{player}: Use a Nature Token ({nature_tokens} left)"):
105
- if nature_tokens > 0:
106
- # Logic to use a nature token
107
- st.write(f"{player} used a Nature Token!")
108
- game_state['players'][player]['nature_tokens'] -= 1
109
- save_game_state(game_state)
110
- else:
111
- st.warning("No Nature Tokens left!")
112
-
113
-
114
- # Reset Button
115
- if st.button("Reset Game"):
116
- os.remove(save_file) # Delete the save file
117
- game_state = {
118
- 'habitat_stack': random.sample(habitat_tiles * 10, 50),
119
- 'wildlife_stack': random.sample(wildlife_tokens * 10, 50),
120
- 'players': {player: {'habitat': [], 'wildlife': [], 'nature_tokens': 3} for player in players}
121
- }
122
- save_game_state(game_state)
123
- st.experimental_rerun()
124
-
125
- # Game Controls and Instructions
126
- st.write("## Game Controls")
127
- st.write("Use the buttons and select boxes to play the game!")
128
-
129
- ```
130
-
131
-
132
- # Sad Response - Not What I am Looking For:
133
-
134
- ```
135
- import streamlit as st
136
- import numpy as np
137
- from scipy.io.wavfile import write
138
- from scipy import signal
139
- import os
140
- import time
141
-
142
- # Function to generate cricket sound
143
- def generate_cricket_sound(temp):
144
- # Cricket chirp frequency formula
145
- frequency = 4 * temp + 40
146
- fs = 44100 # Sample rate
147
- duration = 3 # seconds
148
- t = np.linspace(0, duration, int(fs * duration), endpoint=False)
149
- chirp = 0.5 * np.sin(2 * np.pi * frequency * t)
150
- return chirp, fs
151
-
152
- # Function to play sound
153
- def play_sound(sound, fs):
154
- write('temp_chirp.wav', fs, sound)
155
- os.system("start temp_chirp.wav")
156
- time.sleep(3)
157
- os.remove('temp_chirp.wav')
158
-
159
- # Streamlit app
160
- st.title('Cricket Chirp Simulator')
161
-
162
- st.markdown("""
163
- This app simulates the sound of cricket chirps based on temperature.
164
- The frequency of cricket chirps correlates with temperature!
165
- """)
166
-
167
- temp = st.slider('Select Temperature (Β°C)', 0, 40, 25)
168
-
169
- if st.button('Generate Cricket Sound'):
170
- chirp, fs = generate_cricket_sound(temp)
171
- play_sound(chirp, fs)
172
- st.success('Playing cricket sound for temperature: {} Β°C'.format(temp))
173
- ```
174
-
175
- But fun and creative. Try again.
176
 
177
 
178
  # Morning AM 12/20/2023
 
8
  ---
9
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
 
13
  # Morning AM 12/20/2023