Gist/motives.py

71 lines
2.8 KiB
Python
Raw Normal View History

2025-02-06 07:43:16 -05:00
# Aside from a few item fixes, this is all generated by AI
import random
import time
class Sim:
# Define the initial values for the motives
MOODS = {
'Hunger': 1.0, # Normal hunger decay per minute
'Bladder': 1.0, # Normal bladder decay per minute
'Energy': 1.0, # Normal energy decay per minute
'Social': 0.5, # Social needs build up slower
'Hygiene': 1.0, # Normal hygiene decay per minute
'Fun': 0.5 # Fun needs build up slower
}
# Define the items in the environment and their effects on the Sim's motives
ITEMS = {
'Bed': {'Energy': 3.0, 'Bladder': -0.2}, # Restores energy but slightly increases bladder pressure
'Toilet': {'Bladder': 3.0, 'Hygiene': -0.5}, # Reduces bladder pressure but needs a bit of cleaning
'Fridge': {'Hunger': 2.0, 'Hygiene': 0.1}, # Reduces hunger but slightly impacts hygiene
'Laptop': {'Social': 2.0, 'Fun': 2.0}, # Reduces social need and provides fun
'Shower': {'Hygiene': 3.0}, # Increases hygiene significantly
'Gym': {'Hygiene': 0.5, 'Energy': -1.5, 'Fun': 2.0} # Increases hygiene, drains energy but provides fun
}
def __init__(self):
# Initialize motives to full
self.motives = {motive: random.randint(50,90) for motive in self.MOODS}
def simulate_minute(self):
# Update motives based on natural decay
for motive, decay in self.MOODS.items():
self.motives[motive] -= decay
# Choose an item to affect the Sim's motives
self.use_item()
# Enforce motive limits
for motive in self.motives:
self.motives[motive] = max(self.motives[motive], 0.0)
self.motives[motive] = min(self.motives[motive], 100.0)
def use_item(self):
item = random.choice(list(self.ITEMS.keys()))
print(f"Time passes, Sim uses: {item}")
for motive, effect in self.ITEMS[item].items():
self.motives[motive] += effect
print(f" {motive}: {'+' if effect > 0 else ''}{effect}")
def show_motives(self):
# Display the current state of the Sim's motives
print("Sim's Motives:")
for motive, value in self.motives.items():
print(f" {motive}: {value:.2f}")
def simulate_time(sim, total_minutes):
# Simulate over the given number of minutes
for minute in range(1, total_minutes + 1):
print(f"\nMinute {minute}:")
sim.show_motives()
sim.simulate_minute()
# Simulate a short delay between each minute
time.sleep(1)
if __name__ == "__main__":
print("Starting Sim Motive Simulation...")
sim = Sim()
simulate_time(sim, 10) # Simulate 10 minutes
sim.show_motives()
print("Simulation completed.")