AIRaja commited on
Commit
b5d6e04
·
verified ·
1 Parent(s): c0d38da

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import random
3
+
4
+ def initialize_game():
5
+ if 'money' not in st.session_state:
6
+ st.session_state.money = 100
7
+ st.session_state.heat = 0 # Police attention
8
+ st.session_state.message = "You start in a run-down apartment with $100. What do you do?"
9
+
10
+ def commit_crime(crime, risk, reward):
11
+ if random.random() < risk: # Chance of getting caught
12
+ st.session_state.heat += random.randint(10, 30)
13
+ st.session_state.money -= random.randint(10,50)
14
+ st.session_state.message = f"You got caught {crime}! You lost money and gained heat."
15
+ else:
16
+ st.session_state.money += reward
17
+ st.session_state.heat += random.randint(1, 5)
18
+ st.session_state.message = f"You successfully {crime}! You earned ${reward}."
19
+
20
+ def main():
21
+ st.title("Liberty City Life (Very Simplified)")
22
+ initialize_game()
23
+
24
+ st.write(f"Money: ${st.session_state.money}, Heat: {st.session_state.heat}")
25
+ st.write(st.session_state.message)
26
+
27
+ col1, col2 = st.columns(2)
28
+
29
+ with col1:
30
+ if st.button("Steal a car (risky)"):
31
+ commit_crime("stealing a car", 0.6, 200)
32
+
33
+ if st.button("Mug someone (easy)"):
34
+ commit_crime("mugging someone", 0.3, 50)
35
+
36
+ with col2:
37
+ if st.button("Work a day job (safe)"):
38
+ st.session_state.money += 100
39
+ st.session_state.heat -= min(st.session_state.heat, 5)
40
+ st.session_state.message = "You worked a day job and earned $100. Heat reduced."
41
+
42
+ if st.button("Go to sleep (reduce heat)"):
43
+ st.session_state.heat = max(0, st.session_state.heat - 20)
44
+ st.session_state.message = "You got some sleep. Heat reduced."
45
+
46
+ if st.session_state.heat > 100:
47
+ st.write("The cops are after you! Game over!")
48
+ del st.session_state.money
49
+ del st.session_state.heat
50
+
51
+
52
+ if __name__ == "__main__":
53
+ main()