Initial commit

This commit is contained in:
Tony Bark 2025-02-06 07:43:16 -05:00
commit e12b508072
3 changed files with 101 additions and 0 deletions

7
README.md Normal file
View file

@ -0,0 +1,7 @@
# Tony Bark's Gist
Random commits of code in the public domain.
## License
I hereby waive this project under the public domain - see [UNLICENSE](UNLICENSE) for details.

24
UNLICENSE Normal file
View file

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

70
motives.py Normal file
View file

@ -0,0 +1,70 @@
# 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.")