code a life preview game
- User
code a life preview game
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
code a life preview game
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I'll help you create a simple life preview game in Python. This game will let players make life choices and see their consequences. Here's a basic version:
import random
class LifeGame:
def __init__(self):
self.age = 18
self.money = 1000
self.happiness = 50
self.education = 0
self.career = None
def display_stats(self):
print(f"\nCurrent Status:")
print(f"Age: {self.age}")
print(f"Money: ${self.money}")
print(f"Happiness: {self.happiness}%")
print(f"Education Level: {self.education}")
print(f"Career: {self.career or 'None'}")
def make_choice(self, options):
print("\nWhat would you like to do?")
for i, option in enumerate(options, 1):
print(f"{i}. {option}")
while True:
try:
choice = int(input("Enter your choice (number): "))
if 1 <= choice <= len(options):
return choice
print("Invalid choice. Try again.")
except ValueError:
print("Please enter a number.")
def play_turn(self):
options = [
"Go to college",
"Get a job",
"Start a business",
"Take a year off"
]
choice = self.make_choice(options)
if choice == 1: # Go to college
self.money -= 5000
self.education += 1
self.happiness -= 10
print("\nYou attended college for a year.")
print("You gained knowledge but lost money and some happiness.")
elif choice == 2: # Get a job
if self.education >= 1:
self.money += 8000
self.career = "Office Worker"
else:
self.money += 4000
self.career = "Entry Level Worker"
self.happiness -= 5
print(f"\nYou got a job as {self.career}.")
print("You earned money but lost some happiness.")
elif choice == 3: # Start a business
success = random.random()
if success > 0.7:
self.money += 10000
self.happiness += 20
print("\nYour business was successful!")
else:
self.money -= 5000
self.happiness -= 20
print("\nYour business struggled this year.")
elif choice == 4: # Take a year off
self.money -= 2000
self.happiness += 30
print("\nYou took a year off to travel and relax.")
print("You gained happiness but spent some money.")
self.age += 1
def main():
print("Welcome to Life Preview!")
print("Make choices and see how they affect your life.")
game = LifeGame()
while game.age < 25: # Play until age 25
game.display_stats()
game.play_turn()
if game.money < 0:
print("\nGame Over! You ran out of money!")
break
print("\nGame Over! Here are your final stats:")
game.display_stats()
if __name__ == "__main__":
main()
This game features:
Would you like me to explain how any part works in more detail or add more features to make it more complex?