Skip to content
TheChatArchiveThe Chat Archive
grok-3-preview-02-24· xAIHugging Face LMArena Human Preference 140K

Make a game of farming simulator in python

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-pro’s answer.
  1. User

    Make a game of farming simulator in python

  2. Assistant

    Creating a simple farming simulator game in Python can be a fun project! Below is a basic text-based farming simulator where the player can plant crops, harvest them, manage resources, and deal with random events like weather. This example uses basic Python concepts like loops, conditionals, and functions, and it can be expanded with more features.

    Features of the Game:

    1. Player Resources: Money, seeds, and crops.
    2. Actions: Plant crops, harvest crops, buy seeds, and check status.
    3. Random Events: Weather affects crop growth (e.g., drought, rain, pests).
    4. Time System: Days pass, and crops take time to grow.

    Code for the Farming Simulator:

    import random
    import time
    
    class FarmingSimulator:
        def __init__(self):
            self.money = 100  # Starting money
            self.seeds = 10   # Starting seeds
            self.crops = 0    # Harvested crops
            self.planted_crops = 0  # Crops currently growing
            self.day = 1      # Current day
            self.growth_time = 3  # Days needed for crops to grow
            self.growth_progress = 0  # Tracks growth of planted crops
            self.weather = "Sunny"  # Current weather
    
        def display_status(self):
            print("\n=== Farm Status ===")
            print(f"Day: {self.day}")
            print(f"Weather: {self.weather}")
            print(f"Money: ${self.money}")
            print(f"Seeds: {self.seeds}")
            print(f"Harvested Crops: {self.crops}")
            print(f"Planted Crops: {self.planted_crops}")
            if self.planted_crops > 0:
                print(f"Crop Growth Progress: {self.growth_progress}/{self.growth_time} days")
    
        def plant_crops(self):
            if self.seeds <= 0:
                print("You don't have any seeds! Buy some from the shop.")
                return
            seeds_to_plant = int(input(f"How many seeds do you want to plant? (You have {self.seeds}): "))
            if seeds_to_plant > self.seeds:
                print("You don't have enough seeds!")
            elif seeds_to_plant <= 0:
                print("You must plant at least 1 seed!")
            else:
                self.seeds -= seeds_to_plant
                self.planted_crops += seeds_to_plant
                self.growth_progress = 0
                print(f"Planted {seeds_to_plant} crops. They will be ready in {self.growth_time} days.")
    
        def harvest_crops(self):
            if self.planted_crops == 0:
                print("You don't have any crops to harvest!")
            elif self.growth_progress < self.growth_time:
                print(f"Your crops aren't ready yet! Wait {self.growth_time - self.growth_progress} more days.")
            else:
                harvested = self.planted_crops
                self.crops += harvested
                self.planted_crops = 0
                self.growth_progress = 0
                print(f"Harvested {harvested} crops! You now have {self.crops} crops in storage.")
    
        def buy_seeds(self):
            seed_price = 5
            print(f"Seeds cost ${seed_price} each.")
            seeds_to_buy = int(input(f"How many seeds do you want to buy? (You have ${self.money}): "))
            total_cost = seeds_to_buy * seed_price
            if seeds_to_buy <= 0:
                print("You must buy at least 1 seed!")
            elif total_cost > self.money:
                print("You don't have enough money!")
            else:
                self.money -= total_cost
                self.seeds += seeds_to_buy
                print(f"Bought {seeds_to_buy} seeds for ${total_cost}. You now have {self.seeds} seeds.")
    
        def sell_crops(self):
            crop_price = 10
            if self.crops <= 0:
                print("You don't have any crops to sell!")
                return
            crops_to_sell = int(input(f"How many crops do you want to sell? (You have {self.crops}): "))
            if crops_to_sell > self.crops:
                print("You don't have enough crops!")
            elif crops_to_sell <= 0:
                print("You must sell at least 1 crop!")
            else:
                total_earned = crops_to_sell * crop_price
                self.money += total_earned
                self.crops -= crops_to_sell
                print(f"Sold {crops_to_sell} crops for ${total_earned}. You now have ${self.money}.")
    
        def random_weather(self):
            weather_types = ["Sunny", "Rainy", "Drought", "Pests"]
            self.weather = random.choice(weather_types)
            if self.weather == "Rainy":
                print("It's rainy! Your crops grow faster.")
                self.growth_progress += 2
            elif self.weather == "Drought":
                print("A drought has struck! Your crops are suffering.")
                self.growth_progress -= 1
                if self.growth_progress < 0:
                    self.growth_progress = 0
            elif self.weather == "Pests":
                print("Pests have attacked! You lost some crops.")
                self.planted_crops = max(0, self.planted_crops - random.randint(1, self.planted_crops // 2))
            else:
                print("It's sunny! Your crops are growing normally.")
                self.growth_progress += 1
    
        def next_day(self):
            self.day += 1
            self.random_weather()
            if self.growth_progress >= self.growth_time and self.planted_crops > 0:
                print("Your crops are ready to harvest!")
    
        def play(self):
            print("Welcome to Farming Simulator!")
            while True:
                self.display_status()
                print("\n=== Actions ===")
                print("1. Plant crops")
                print("2. Harvest crops")
                print("3. Buy seeds")
                print("4. Sell crops")
                print("5. Next day")
                print("6. Quit")
                choice = input("What would you like to do? (1-6): ")
    
                if choice == "1":
                    self.plant_crops()
                elif choice == "2":
                    self.harvest_crops()
                elif choice == "3":
                    self.buy_seeds()
                elif choice == "4":
                    self.sell_crops()
                elif choice == "5":
                    self.next_day()
                elif choice == "6":
                    print("Thanks for playing Farming Simulator!")
                    break
                else:
                    print("Invalid choice! Please select a number between 1 and 6.")
                time.sleep(1)  # Pause for readability
    
    if __name__ == "__main__":
        game = FarmingSimulator()
        game.play()
    

    How to Play:

    1. Run the code in a Python environment.
    2. The game starts with a set amount of money, seeds, and crops.
    3. Each day, you can:
      • Plant crops (if you have seeds).
      • Harvest crops (once they are fully grown).
      • Buy seeds (if you have money).
      • Sell harvested crops (to earn money).
      • Move to the next day (to progress crop growth and trigger random weather events).
    4. Random weather events (sunny, rainy, drought, pests) affect your crops' growth or survival.
    5. The goal is to manage your resources wisely and grow your farm!

    Explanation of the Code:

    • Class FarmingSimulator: Manages the game state (money, seeds, crops, etc.) and defines all game mechanics.
    • Methods:
      • display_status(): Shows the current state of the farm.
      • plant_crops(): Allows planting seeds, which take time to grow.
      • harvest_crops(): Collects fully grown crops.
      • buy_seeds(): Purchases seeds using money.
      • sell_crops(): Sells harvested crops for money.
      • random_weather(): Simulates weather events that affect crop growth.
      • next_day(): Advances the game by one day and triggers weather events.
      • play(): Main game loop that handles user input and game flow.
    • Random Events: Weather can speed up growth (rain), slow it down (drought), or destroy crops (pests).

    Possible Enhancements:

    1. Graphics: Use a library like Pygame to add a graphical interface with fields, crops, and animations.
    2. More Crops: Add different types of crops with varying growth times, costs, and selling prices.
    3. Upgrades: Allow the player to buy tools, fertilizers, or irrigation systems to improve crop growth.
    4. Seasons: Introduce seasons that affect crop growth and availability.
    5. Challenges: Add goals or challenges, like earning a certain amount of money in a set number of days.
    6. Save/Load: Implement a save/load system to store game progress.

    This is a basic version of a farming simulator, but it provides a solid foundation for adding more features and complexity. Have fun coding and farming! 🌾

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.