awacke1 commited on
Commit
a0b9333
Β·
verified Β·
1 Parent(s): 8f39283

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import numpy as np
3
 
4
  # Helper functions for number theory-based emoji placement
 
5
  def is_prime(n):
6
  if n <= 1:
7
  return False
@@ -14,28 +15,40 @@ def fib_sequence(n):
14
  fib_seq = [0, 1]
15
  while fib_seq[-1] + fib_seq[-2] <= n:
16
  fib_seq.append(fib_seq[-1] + fib_seq[-2])
17
- return fib_seq[2:] # Exclude first two numbers for this use case
18
 
19
  # Expanded set of emojis for landscape elements
20
- emoji_set = ["🌲", "🌳", "πŸƒ", "🌲", "🌿", "πŸ„", "🏠", "🏰", "πŸ—Ό", "πŸ›€οΈ", "🌊", "🏞️", "🌁", "🌾", "🏜️", "🏝️", "πŸ›–", "πŸ›€οΈ", "πŸ›£οΈ", "πŸ•οΈ", "πŸŒ‹", "⛰️", "🧱", "🌡", "🍁", "🌼", "🌻", "🌺", "🏑", "πŸ—ΊοΈ"]
 
 
 
 
 
 
21
 
22
  # Locations and emoji grid maps initialization
 
23
  def initialize_locations(size):
24
  """Initialize different locations with unique emoji grids."""
25
- # Placeholder for location initialization logic
26
- # Randomly fill grids with emojis from emoji_set for each location
27
- np.random.seed(42) # Optional: for reproducible emoji distributions
28
  locations = {
29
- 'forest edge': np.random.choice(emoji_set, (size, size)),
30
- 'deep forest': np.random.choice(emoji_set, (size, size)),
31
- # Additional locations can be added here
 
 
 
 
 
32
  }
33
  return locations
34
 
35
  # Directions for movement
 
36
  directions = {"North": (-1, 0), "South": (1, 0), "West": (0, -1), "East": (0, 1)}
37
 
38
  # Movement and emoji map update functions
 
39
  def move_emojis(locations, current_location, direction):
40
  """Shift emojis in the specified direction with wrap-around for the current location."""
41
  dx, dy = directions[direction]
@@ -43,19 +56,21 @@ def move_emojis(locations, current_location, direction):
43
  return locations
44
 
45
  # Streamlit application setup
 
46
  def main():
47
  st.title("Explore the Emoji World")
 
48
 
49
- size = st.sidebar.slider("Grid Size", 5, 40, 10)
50
  if 'locations' not in st.session_state:
51
  st.session_state.locations = initialize_locations(size)
52
-
53
  current_location = st.sidebar.selectbox("Select location", options=list(st.session_state.locations.keys()))
54
  emoji_map = st.session_state.locations[current_location]
55
  map_str = "\n".join(["".join(row) for row in emoji_map])
56
  st.text(map_str)
57
 
58
  direction = st.sidebar.selectbox("Move direction", ["None", "North", "South", "East", "West"])
 
59
  if direction != "None":
60
  st.session_state.locations = move_emojis(st.session_state.locations, current_location, direction)
61
  st.experimental_rerun()
 
2
  import numpy as np
3
 
4
  # Helper functions for number theory-based emoji placement
5
+
6
  def is_prime(n):
7
  if n <= 1:
8
  return False
 
15
  fib_seq = [0, 1]
16
  while fib_seq[-1] + fib_seq[-2] <= n:
17
  fib_seq.append(fib_seq[-1] + fib_seq[-2])
18
+ return fib_seq[2:] # Exclude first two numbers for this use case
19
 
20
  # Expanded set of emojis for landscape elements
21
+
22
+ nature_emojis = ["🌲", "🌳", "πŸƒ", "🌿", "πŸ„", "🌊", "🏞️", "🌁", "🌾", "🏜️", "🏝️", "πŸŒ‹", "⛰️", "🌡", "🍁", "🌼", "🌻", "🌺"]
23
+ building_emojis = ["🏠", "🏰", "πŸ—Ό", "πŸ›–", "πŸ•οΈ", "🧱", "🏑"]
24
+ infrastructure_emojis = ["πŸ›€οΈ", "πŸ›£οΈ", "πŸ—ΊοΈ"]
25
+ bird_emojis = ["🦜", "🦚", "πŸ¦‰", "πŸ¦†", "πŸ¦…", "🦩", "πŸ•ŠοΈ", "πŸ¦ƒ"]
26
+ animal_emojis = ["πŸ’", "🦍", "🐘", "🦏", "πŸ†", "πŸ…", "πŸƒ", "πŸ‚", "πŸ„", "πŸͺ", "🐫", "πŸ¦™", "🦘", "πŸ¦₯", "🐿️"]
27
+ fish_emojis = ["🐠", "🐟", "🐑", "🦈", "πŸ™", "🐚", "πŸ¦€", "🦞", "🦐", "🐬", "🐳", "πŸ‹"]
28
 
29
  # Locations and emoji grid maps initialization
30
+
31
  def initialize_locations(size):
32
  """Initialize different locations with unique emoji grids."""
33
+ np.random.seed(42) # Optional: for reproducible emoji distributions
 
 
34
  locations = {
35
+ 'forest edge': np.random.choice(nature_emojis + bird_emojis + animal_emojis, (size, size)),
36
+ 'deep forest': np.random.choice(nature_emojis + bird_emojis + animal_emojis, (size, size)),
37
+ 'mountain range': np.random.choice(nature_emojis + animal_emojis, (size, size)),
38
+ 'coastal town': np.random.choice(building_emojis + infrastructure_emojis + fish_emojis, (size, size)),
39
+ 'desert oasis': np.random.choice(nature_emojis + animal_emojis, (size, size)),
40
+ 'urban cityscape': np.random.choice(building_emojis + infrastructure_emojis, (size, size)),
41
+ 'tropical island': np.random.choice(nature_emojis + bird_emojis + fish_emojis, (size, size)),
42
+ 'savanna plains': np.random.choice(nature_emojis + animal_emojis + bird_emojis, (size, size)),
43
  }
44
  return locations
45
 
46
  # Directions for movement
47
+
48
  directions = {"North": (-1, 0), "South": (1, 0), "West": (0, -1), "East": (0, 1)}
49
 
50
  # Movement and emoji map update functions
51
+
52
  def move_emojis(locations, current_location, direction):
53
  """Shift emojis in the specified direction with wrap-around for the current location."""
54
  dx, dy = directions[direction]
 
56
  return locations
57
 
58
  # Streamlit application setup
59
+
60
  def main():
61
  st.title("Explore the Emoji World")
62
+ size = st.sidebar.slider("Grid Size", 5, 50, 20)
63
 
 
64
  if 'locations' not in st.session_state:
65
  st.session_state.locations = initialize_locations(size)
66
+
67
  current_location = st.sidebar.selectbox("Select location", options=list(st.session_state.locations.keys()))
68
  emoji_map = st.session_state.locations[current_location]
69
  map_str = "\n".join(["".join(row) for row in emoji_map])
70
  st.text(map_str)
71
 
72
  direction = st.sidebar.selectbox("Move direction", ["None", "North", "South", "East", "West"])
73
+
74
  if direction != "None":
75
  st.session_state.locations = move_emojis(st.session_state.locations, current_location, direction)
76
  st.experimental_rerun()