Code a game, a idea is yourselfs. Anything you want to code, no limits as you like.
- User
Code a game, a idea is yourselfs. Anything you want to code, no limits as you like.
Assistant
I'll create a text-based adventure RPG called "The Crystal Caverns" - an exploration game where you navigate mysterious caves, fight creatures, collect treasures, and search for the legendary Crystal of Eternal Light!
import random import time class Player: def __init__(self, name): self.name = name self.health = 100 self.max_health = 100 self.attack = 15 self.defense = 5 self.gold = 50 self.inventory = ["Health Potion", "Torch"] self.level = 1 self.experience = 0 self.crystals_found = 0 def take_damage(self, damage): actual_damage = max(1, damage - self.defense) self.health -= actual_damage return actual_damage def heal(self, amount): self.health = min(self.max_health, self.health + amount) def gain_experience(self, exp): self.experience += exp if self.experience >= self.level * 20: self.level_up() def level_up(self): self.level += 1 self.max_health += 20 self.health = self.max_health self.attack += 5 self.defense += 2 print(f"\n🎉 Level up! You are now level {self.level}!") print(f"Health increased to {self.max_health}, Attack: {self.attack}, Defense: {self.defense}") class Monster: def __init__(self, name, health, attack, defense, exp_reward, gold_reward): self.name = name self.health = health self.max_health = health self.attack = attack self.defense = defense self.exp_reward = exp_reward self.gold_reward = gold_reward def create_monster(): monsters = [ Monster("Cave Rat", 25, 8, 1, 5, random.randint(5, 15)), Monster("Goblin Scout", 40, 12, 3, 10, random.randint(10, 25)), Monster("Stone Golem", 60, 18, 8, 20, random.randint(20, 40)), Monster("Shadow Wraith", 35, 20, 2, 15, random.randint(15, 30)), Monster("Crystal Spider", 45, 15, 5, 12, random.randint(12, 28)) ] return random.choice(monsters) def print_slow(text, delay=0.03): for char in text: print(char, end='', flush=True) time.sleep(delay) print() def display_stats(player): print(f"\n{'='*50}") print(f"🏛️ {player.name} - Level {player.level}") print(f"❤️ Health: {player.health}/{player.max_health}") print(f"⚔️ Attack: {player.attack} | 🛡️ Defense: {player.defense}") print(f"💰 Gold: {player.gold} | ✨ Experience: {player.experience}") print(f"💎 Crystals Found: {player.crystals_found}") print(f"🎒 Inventory: {', '.join(player.inventory)}") print(f"{'='*50}") def combat(player, monster): print(f"\n⚔️ A wild {monster.name} appears!") print(f"Monster Health: {monster.health}") while monster.health > 0 and player.health > 0: print(f"\nWhat do you want to do?") print("1. Attack") print("2. Use Health Potion") print("3. Try to flee") choice = input("Choose (1-3): ").strip() if choice == "1": # Player attacks damage = random.randint(player.attack - 3, player.attack + 3) actual_damage = max(1, damage - monster.defense) monster.health -= actual_damage print(f"You deal {actual_damage} damage to the {monster.name}!") if monster.health <= 0: print(f"You defeated the {monster.name}!") player.gain_experience(monster.exp_reward) player.gold += monster.gold_reward print(f"You gained {monster.exp_reward} experience and {monster.gold_reward} gold!") return True elif choice == "2": if "Health Potion" in player.inventory: heal_amount = random.randint(25, 40) player.heal(heal_amount) player.inventory.remove("Health Potion") print(f"You healed for {heal_amount} health!") else: print("You don't have any health potions!") continue elif choice == "3": if random.random() < 0.3: print("You successfully fled from combat!") return False else: print("You couldn't escape!") # Monster attacks if still alive if monster.health > 0: damage = random.randint(monster.attack - 2, monster.attack + 2) actual_damage = player.take_damage(damage) print(f"The {monster.name} deals {actual_damage} damage to you!") if player.health <= 0: print("💀 You have been defeated...") return False return True def explore_room(player): room_types = [ "combat", "treasure", "crystal", "merchant", "healing_spring", "trap", "empty", "puzzle" ] weights = [30, 20, 10, 5, 8, 12, 10, 5] # Probability weights room_type = random.choices(room_types, weights=weights)[0] if room_type == "combat": monster = create_monster() if combat(player, monster): print("The path ahead is now clear.") else: return False elif room_type == "treasure": treasure_types = ["gold", "potion", "equipment"] treasure = random.choice(treasure_types) if treasure == "gold": gold_found = random.randint(15, 50) player.gold += gold_found print(f"💰 You found a chest containing {gold_found} gold!") elif treasure == "potion": player.inventory.append("Health Potion") print(f"🧪 You found a Health Potion!") elif treasure == "equipment": upgrades = ["Sharp Sword (+3 Attack)", "Iron Shield (+2 Defense)", "Lucky Charm (+1 Defense)"] upgrade = random.choice(upgrades) if "Attack" in upgrade: player.attack += 3 else: player.defense += 2 print(f"⚔️ You found: {upgrade}!") elif room_type == "crystal": player.crystals_found += 1 player.gain_experience(25) print(f"💎 You discovered a magical crystal! You feel more powerful.") print(f"Crystals found: {player.crystals_found}/5") elif room_type == "merchant": print(f"🏪 You encounter a mysterious merchant!") print(f"'Greetings, traveler! I have potions for sale.'") print(f"Health Potion - 20 gold") if player.gold >= 20: buy = input("Buy a potion? (y/n): ").lower() if buy == 'y': player.gold -= 20 player.inventory.append("Health Potion") print("Transaction complete!") elif room_type == "healing_spring": heal_amount = random.randint(20, 35) player.heal(heal_amount) print(f"⛲ You found a magical healing spring and recovered {heal_amount} health!") elif room_type == "trap": damage = random.randint(5, 15) player.take_damage(damage) print(f"💥 You stepped on a trap and took {damage} damage!") if player.health <= 0: return False elif room_type == "puzzle": print(f"🧩 You encounter an ancient puzzle!") riddle = random.choice([ ("I have keys but no locks. I have space but no room. What am I?", "keyboard"), ("What gets wetter the more it dries?", "towel"), ("I'm tall when I'm young, and short when I'm old. What am I?", "candle") ]) print(f"Riddle: {riddle[0]}") answer = input("Your answer: ").lower().strip() if answer == riddle[1]: reward = random.randint(30, 60) player.gold += reward player.gain_experience(15) print(f"🎯 Correct! You found {reward} gold hidden behind the puzzle!") else: print(f"❌ Wrong answer! The correct answer was: {riddle[1]}") else: # empty room discoveries = [ "You find ancient markings on the wall.", "A cool breeze flows through this chamber.", "You hear distant water dripping.", "Strange symbols glow faintly on the ceiling.", "This room feels eerily quiet." ] print(f"🏛️ {random.choice(discoveries)}") return True def main_game(): print_slow("🏛️ Welcome to THE CRYSTAL CAVERNS 🏛️") print_slow("A mysterious adventure awaits...") name = input("\nEnter your hero's name: ").strip() or "Adventurer" player = Player(name) print_slow(f"\nWelcome, {player.name}! You stand before the entrance to the legendary Crystal Caverns.") print_slow("Legend speaks of 5 magical crystals hidden within these depths.") print_slow("Find all 5 crystals to claim the Crystal of Eternal Light!") rooms_explored = 0 while player.health > 0: display_stats(player) if player.crystals_found >= 5: print_slow("\n🎊 CONGRATULATIONS! 🎊") print_slow("You have found all 5 magical crystals!") print_slow("The Crystal of Eternal Light materializes before you!") print_slow(f"You completed your quest in {rooms_explored} rooms!") print_slow("You are now a legend of the Crystal Caverns!") break print(f"\n🗺️ You are deep in the caverns (Rooms explored: {rooms_explored})") print("What would you like to do?") print("1. Explore deeper into the caverns") print("2. Rest and recover (costs 10 gold)") print("3. Check inventory") print("4. Quit adventure") choice = input("Choose your action (1-4): ").strip() if choice == "1": print_slow(f"\n{player.name} ventures deeper into the mysterious caverns...") if explore_room(player): rooms_explored += 1 else: if player.health <= 0: print_slow(f"\n💀 Game Over! {player.name} has fallen in the Crystal Caverns.") print_slow(f"You explored {rooms_explored} rooms and found {player.crystals_found} crystals.") break elif choice == "2": if player.gold >= 10: player.gold -= 10 heal_amount = random.randint(15, 30) player.heal(heal_amount) print(f"😴 You rest peacefully and recover {heal_amount} health.") else: print("💸 You don't have enough gold to rest safely (need 10 gold).") elif choice == "3": print(f"\n🎒 Your inventory contains:") for item in player.inventory: print(f" - {item}") if not player.inventory: print(" Your inventory is empty.") elif choice == "4": print_slow(f"👋 {player.name} exits the Crystal Caverns.") print_slow(f"Final Stats: Level {player.level}, {player.crystals_found} crystals found") break else: print("❓ Invalid choice. Please choose 1-4.") if __name__ == "__main__": main_game()This is "The Crystal Caverns" - a complete text-based RPG adventure game! Here's what makes it fun:
🎮 Game Features:
- Character progression with leveling, stats, and equipment
- Dynamic combat system with strategy choices
- 8 different room types including treasures, puzzles, merchants, and traps
- Quest objective: Find 5 magical crystals to win
- Random encounters keep each playthrough unique
- Resource management with health, gold, and inventory
🎯 Gameplay Elements:
- Fight various monsters (Cave Rats, Goblins, Stone Golems, etc.)
- Solve riddles for bonus rewards
- Find treasure chests and magical springs
- Buy items from mysterious merchants
- Level up and grow stronger as you explore
🎲 Replayability: Every room is randomly generated, so each adventure feels different. The balance between risk and reward keeps you making interesting decisions!
Want to play? Just run the code and start your adventure in the Crystal Caverns! The game uses simple text commands and tells an engaging story as you explore deeper into the mysterious underground world.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.