I’ve been singularly unimpressed during my (admittedly) brief fiddling around with ChatGPT and other AI engines to date, but thought I’d give DeepSeek a quick try so that it could disappoint me as well.
Among the almost random things I found myself typing into it were the words “Write a Zorklike game”. I was far less underwhelmed than I expected when it responded moments later with a game called “Mystical Quest” written in Python.
While “Mystical Quest” isn’t likely to win any awards, for anyone here who’s interested, here it is, together with DeepSeek’s full response to my four word request:
New chat
Write a zorklike game
DeepSeek Response:
Okay, I need to write a Zork-like game. Let me start by recalling what Zork is like. It’s a text-based adventure game where the player explores a world, solves puzzles, collects items, and interacts with the environment through text commands. So the game should have different rooms, items to pick up, maybe some puzzles or obstacles, and different possible endings based on the player’s actions.
First, I should outline the structure. Let’s have a few interconnected rooms. Maybe a simple layout: starting in a forest, then a cave, a clearing, etc. Each room will have a description and possible items or actions. The player can move in directions like north, south, east, west. Also, they can look around, take items, use items, etc.
Items are important. Let’s think of a few key items needed to progress. For example, a key to unlock a door, a lantern to light dark areas, a sword to defeat a monster. Maybe the player needs to collect these items in order to proceed through different areas.
Next, puzzles. A classic one is a dark room that requires a light source. If the player enters without a lantern, they can’t see and might get hurt or stuck. Another could be a locked gate that needs a key. Maybe a riddle from a guardian that needs to be answered correctly.
I need to map out the rooms and their connections. Let’s say the game starts in the Mystical Forest. From there, the player can go north to a Dark Cave, but it’s too dark unless they have the lantern. East might lead to an Enchanted Clearing with a key. West could be a River that they need to cross, maybe using a raft they have to find.
Wait, but keeping it simple for now. Maybe start with the forest, leading to a cave (needs lantern), and a clearing with a key. The cave has a gate that requires the key, behind which is a dragon that needs to be defeated with a sword. The sword is in another location, maybe the river area, which requires another item like a raft to reach.
Wait, maybe too complex. Let’s scale back. Let’s have the forest, cave, clearing, and maybe a tower. The player needs to find a key in the clearing to unlock the cave, where there’s a treasure but guarded by a creature. The lantern is in the forest, which they need to take to enter the cave. If they go into the cave without the lantern, they get attacked by bats and lose.
So the flow could be: start in forest, take lantern, go north to cave (dark, need lantern), then use key from clearing (east from forest) to unlock gate in cave, get treasure. Alternatively, if they go west to the river without a raft, they can’t proceed. The raft could be in the clearing, but maybe that’s complicating. Let’s keep it to a few rooms.
Let me sketch the rooms:
- Mystical Forest (starting point)
-
Description: Tall trees, sunlight filtering through. Paths north, east, west.
-
Items: Lantern (needs to be taken)
-
North leads to Dark Cave (requires lantern)
-
East leads to Enchanted Clearing (has key)
-
West leads to Rapid River (needs raft, which is maybe in another location)
- Enchanted Clearing
-
Description: A peaceful area with a pedestal holding a key.
-
Items: Rusty Key (take it)
-
West back to Forest
- Dark Cave
-
Description: Dark, player needs lantern. If they have it, they see a gate with a lock.
-
Locked gate requires key. If unlocked, leads to Treasure Chamber.
-
If no lantern, entering cave results in being lost and game over.
- Treasure Chamber
-
Description: Glowing treasure chest. Opening it wins the game.
-
But maybe a guardian? Like a dragon. If the player has a sword, they can defeat it. Otherwise, game over.
Wait, so maybe the sword is another item. Where would that be? Maybe in the Rapid River area. If the player goes west from the forest to the river, they need a raft (item from somewhere) to cross. On the other side is a hidden grotto with a sword. But that adds more rooms and items. Let me see.
Alternatively, the sword could be in the Enchanted Clearing, but that’s where the key is. Maybe the clearing has both the key and the sword, but that’s too much in one place. Or perhaps the key is in the clearing, the sword in the cave but behind a puzzle.
Hmm. Let me simplify. The main goal is to get the treasure. To do that, the player needs the key (from clearing) to unlock the gate in the cave (which requires lantern to enter). Once they unlock the gate, they face a dragon. If they have a sword, they win; else, they lose. So the sword would be another item, perhaps in another location.
But maybe the player can choose to fight or negotiate. Let’s say in the Treasure Chamber, the dragon asks a riddle. Answering correctly allows passage, else combat. If they have a sword, combat is successful. If not, they lose.
Alternatively, maybe the lantern can be used to scare the dragon. So using the lantern in the Treasure Chamber scares the dragon away.
But I need to define the possible commands. The player can type things like ‘go north’, ‘take lantern’, ‘use key on gate’, ‘attack dragon with sword’, etc.
So, step by step:
Player starts in Mystical Forest. They can look around, take the lantern. Then go east to Enchanted Clearing, take the key. Back to forest, go north to Dark Cave. With lantern, enter. See the gate, use key. Enter Treasure Chamber, face dragon. If they have a sword, attack and win. If not, maybe use lantern to scare it, or answer a riddle.
Wait, where would the sword be? Maybe in the cave, but the player needs to explore. Or in the Rapid River area. Let’s say if they go west from the forest to the river, they need a raft. If they have a raft (maybe found in the clearing), they can cross and find the sword.
But this adds more steps. Let’s see if that’s manageable.
Alternatively, the sword is in the forest, but hidden. Maybe the player needs to ‘look’ in the forest again after taking the lantern to find it under a bush. But that might be confusing.
Alternatively, in the Dark Cave, before the gate, there’s a side passage where the sword is, but only visible if the player has the lantern.
This is getting a bit complex. To keep it simple, maybe the sword is in the Enchanted Clearing along with the key. So the player can take both items. Then in the Treasure Chamber, they can use the sword to defeat the dragon.
But then the puzzle is straightforward. Maybe add a riddle in the cave gate. The key is needed, but also a riddle must be solved. For example, the gate has a riddle inscribed, and the player must answer correctly even after using the key.
Alternatively, the key is in the clearing, the lantern in the forest, the sword maybe in the cave but behind a puzzle.
Wait, let’s outline the items and their locations:
-
Lantern: Forest (starting room)
-
Rusty Key: Enchanted Clearing (east from forest)
-
Sword: Maybe in the cave, but only accessible after solving a puzzle, like moving a boulder with a lever found elsewhere.
But this might complicate things. Let’s stick to a simpler structure.
Proposed flow:
-
Forest: take lantern. Exits: north (cave), east (clearing), west (river).
-
Clearing: take key. Exit west to forest.
-
Cave (needs lantern): use key to open gate. Inside, treasure chamber with dragon. Need sword to defeat dragon.
-
Sword is in another location, say across the river (west from forest). To cross river, need raft. Raft is in clearing, but player needs to ‘take raft’ from clearing. So in the clearing, there’s a key and a raft.
Wait, but the player might not realize they need the raft. Maybe the river description says “A swift river blocks your path. A raft is tied to the shore here.” So in the river room, the raft is present, but the player needs to ‘take raft’ or ‘use raft’ to cross.
Wait, maybe the river room is west from forest. When the player goes west, they arrive at the river. The description says “You stand before a raging river. A small raft is moored at the shore.” The player can ‘take raft’ to add it to inventory. Then, to cross, they can ‘go west’ again, using the raft.
Once across, they find a hidden grotto with the sword.
So the steps would be:
-
From forest, go west to river. Take raft.
-
Go west again (using raft) to Hidden Grotto. Take sword.
-
Return to forest, go north to cave (with lantern), use key on gate, enter treasure chamber, use sword on dragon.
So the items are lantern, key, raft, sword.
But this adds more complexity. Let me check if this is manageable in a text game. Each room needs to have a description, possible items, exits, and any conditions for moving (like needing an item).
Let me outline the rooms:
Mystical Forest:
-
Description: You are in a mystical forest. Tall trees tower above you. Paths lead north, east, and west. A lantern lies on the ground.
-
Items: Lantern (can be taken)
-
Exits: North (to Dark Cave, requires lantern in inventory to enter), East (Enchanted Clearing), West (Rapid River)
Enchanted Clearing:
-
Description: A serene clearing. Sunlight illuminates a pedestal with a rusty key. To the west is the forest.
-
Items: Rusty Key (can be taken)
-
Exits: West (Forest)
Rapid River:
-
Description: A raging river blocks your path. A small raft is moored here.
-
Items: Raft (can be taken)
-
Exits: East (Forest), West (requires raft to cross to Hidden Grotto)
Hidden Grotto:
-
Description: A hidden grotto behind the river. A gleaming sword is stuck in a stone.
-
Items: Sword (can be taken)
-
Exits: East (back to River, using raft)
Dark Cave:
-
Description: A dark cave entrance. It’s too dark to see inside. (If player has lantern, description changes to: The lantern lights the way, revealing a locked iron gate to the north.)
-
Exits: North (to Treasure Chamber, requires key to unlock gate), South (back to Forest)
Treasure Chamber:
-
Description: A chamber filled with treasure. A dragon guards the hoard!
-
When entering, the dragon confronts the player. If the player has the sword, they defeat the dragon and win. Otherwise, the dragon attacks and the player loses.
So the player must collect lantern, key, raft, cross river to get sword, then go to cave, unlock gate, defeat dragon.
That’s a bit involved but manageable. Now, the code structure. Using Python, since it’s good for text games. The game will have a loop, processing commands. Each room is an object or a dictionary with description, items, exits, and any conditions.
The player’s inventory is a list. The current room is tracked. For each move, check if the exit is allowed (e.g., cave requires lantern, river crossing requires raft).
Implementing commands like ‘go [direction]’, ‘take [item]’, ‘use [item]’, ‘inventory’, ‘look’, ‘quit’.
Possible edge cases: trying to take an item not present, using an item in the wrong place, moving without required items.
Let’s outline the code structure:
-
Define rooms as a dictionary, each room having description, items, exits (which may have conditions), and any special actions.
-
Player inventory starts empty.
-
Current room starts as ‘Mystical Forest’.
-
Game loop: print description, get input, process command.
Handling special conditions, like in the Dark Cave, if the player doesn’t have the lantern, moving north from forest to cave is allowed, but results in a game over.
Wait, no. The Dark Cave is a separate room. So the Mystical Forest’s north exit leads to Dark Cave, but entering Dark Cave without lantern results in a game over.
So in the room definitions, the exit from Forest to Dark Cave is allowed, but upon entering Dark Cave, check if the player has the lantern. If not, game over.
Alternatively, the exit to Dark Cave is only available if the player has the lantern. But that’s more complex.
Probably better to let the player enter the cave, but upon arriving, check for the lantern. If not present, describe being lost in the dark and game over.
Similarly, in the Treasure Chamber, check for the sword when confronting the dragon.
Now, code steps:
- Define the rooms with their properties.
Sample room structure:
rooms = {
‘Mystical Forest’: {
‘description’: ‘You are in a mystical forest…’,
‘items’: [‘lantern’],
‘exits’: {‘north’: ‘Dark Cave’, ‘east’: ‘Enchanted Clearing’, ‘west’: ‘Rapid River’},
‘special’: None
},
‘Dark Cave’: {
‘description’: ‘A dark cave entrance…’,
‘items’: [ ],
‘exits’: {‘south’: ‘Mystical Forest’},
‘special’: {
‘entry’: {
‘condition’: {‘item’: ‘lantern’, ‘negated’: False},
‘success’: ‘The lantern lights the way, revealing a locked iron gate to the north.’,
‘fail’: ‘It's too dark! You stumble and fall into a pit. Game Over!’,
‘result’: ‘game_over’
},
‘exits’: {‘north’: {‘to’: ‘Treasure Chamber’, ‘condition’: {‘item’: ‘rusty key’}}}
}
},
#Other rooms…
}
But this might get complicated. Alternatively, handle each room’s logic with functions, but for simplicity, use condition checks in the main loop.
Alternatively, when moving to a room, check if any entry conditions are met.
Alternatively, when the player tries to enter a room, check if they have the required items. For example, moving into Dark Cave checks for lantern. If yes, proceed. If not, game over.
Similarly, moving from Dark Cave to Treasure Chamber requires the key.
So in the code, when the player inputs ‘go north’ from Forest, the code checks if the destination is Dark Cave. Then, upon moving there, check if lantern is in inventory. If not, trigger game over.
Similarly, in the Dark Cave, the exit north to Treasure Chamber is only possible if the player has the key (and has used it on the gate, or maybe automatically checks upon moving).
Wait, perhaps when the player is in the Dark Cave and tries to go north, the code checks if the key is in inventory. If yes, they can proceed to Treasure Chamber. If not, the gate is locked.
But how to handle using the key on the gate. Maybe the player needs to ‘use key on gate’ before being able to go north.
Alternatively, the exit is hidden until the key is used. So in the Dark Cave’s description, after using the key, the exit becomes available.
This is getting a bit into the weeds. To manage this, perhaps track the state of certain objects. For example, the gate in the Dark Cave can be ‘locked’ or ‘unlocked’. Initially locked, using the key unlocks it, allowing access to Treasure Chamber.
So variables like gate_locked = True. When the player uses the key on the gate, gate_locked becomes False. Then, when trying to go north from Dark Cave, it checks if gate_locked is False.
This requires adding stateful objects in the rooms. So in the room definitions, track such states.
Hmm. To keep it manageable, perhaps have a dictionary for room states. For example:
room_states = {
‘Dark Cave’: {
‘gate_locked’: True
}
}
Then, when the player uses the key in the Dark Cave, it sets gate_locked to False. Then, when attempting to go north from Dark Cave, check if gate_locked is False. If yes, allow entering Treasure Chamber.
So in code, when processing ‘use key’ in Dark Cave:
if current_room == ‘Dark Cave’ and ‘rusty key’ in inventory:
print(“You unlock the gate with the key.”)
room_states[‘Dark Cave’][‘gate_locked’] = False
inventory.remove(‘rusty key’)
else:
print(“You can’t use that here.”)
Then, when the player tries to go north from Dark Cave:
if room_states[‘Dark Cave’][‘gate_locked’]:
print(“The gate is locked.”)
else:
current_room = ‘Treasure Chamber’
This adds more complexity but allows for puzzle progression.
Similarly, the Rapid River room: if the player tries to go west without the raft, it’s not possible. But with the raft, they can cross to Hidden Grotto.
So, in code, when in Rapid River and input is ‘go west’:
if ‘raft’ in inventory:
current_room = ‘Hidden Grotto’
else:
print(“The river is too dangerous to cross without a raft.”)
But the raft is an item that the player can take from the Rapid River room. Wait, no. The raft is in the Rapid River room, so the player can take it. Then, when trying to cross, use the raft.
Wait, perhaps the raft is in the Rapid River room. The player can take it, adding to inventory. Then, when trying to go west (cross the river), check if the raft is in inventory. If yes, move to Hidden Grotto. But maybe using the raft consumes it, or not.
Alternatively, the raft is a one-time use. Once used to cross, it’s no longer needed. So the player can take the raft from Rapid River, then when going west, the code checks if they have the raft, moves them to Hidden Grotto, and removes the raft from inventory (since it’s left on the other side). But then returning would require another raft, which isn’t present. So maybe the raft remains in inventory, allowing multiple crossings.
Alternatively, the raft is not an inventory item but a condition. Once taken, crossing is allowed. Hmm.
This is getting a bit complicated. Let’s adjust. In the Rapid River room, the player can ‘take raft’, which adds it to inventory. Then, to go west, they need to have the raft. So:
In Rapid River’s exits, west is conditional on having the raft.
But how to represent conditional exits in the room structure. Maybe each exit can have a condition. For example:
exits: {
‘east’: {‘room’: ‘Mystical Forest’, ‘condition’: None},
‘west’: {‘room’: ‘Hidden Grotto’, ‘condition’: ‘raft’}
}
Then, when processing ‘go west’, check if the condition (raft in inventory) is met.
So in code, when moving, check if the exit direction exists, then check if there’s a condition. If condition exists, check if the item is in inventory. If yes, proceed; else, print message.
This requires adjusting the room structure to include conditions for exits.
Alternatively, handle each exit with a function, but that’s more complex.
Alternatively, hardcode the conditions for specific rooms and exits. For example, when in Rapid River and trying to go west, check if ‘raft’ is in inventory.
This is manageable for a small game.
Now, putting it all together.
The rooms:
- Mystical Forest
-
Items: lantern
-
Exits: north (Dark Cave), east (Enchanted Clearing), west (Rapid River)
- Enchanted Clearing
-
Items: rusty key
-
Exits: west (Forest)
- Rapid River
-
Items: raft
-
Exits: east (Forest), west (Hidden Grotto, needs raft)
- Hidden Grotto
-
Items: sword
-
Exits: east (Rapid River)
- Dark Cave
-
Exits: south (Forest), north (Treasure Chamber, needs key used on gate)
-
Entering without lantern: game over
- Treasure Chamber
- Confront dragon: win if have sword, else lose
Now, the code steps:
-
Initialize rooms, player inventory, current room.
-
Game loop: print room description, items, exits.
-
Process player commands.
Implementing ‘go’, ‘take’, ‘use’, ‘inventory’, ‘look’, ‘quit’.
Handling room transitions with conditions.
Also, when entering a room, check for entry conditions (e.g., Dark Cave requires lantern).
Let’s outline some code.
First, the room definitions. Let’s use a dictionary for each room with description, items, exits (as a dictionary mapping directions to room names or conditions), and any entry conditions.
But to handle entry conditions and exit conditions, maybe separate functions.
Alternatively, track the current room and handle each room’s specific logic when entered.
For example:
When the player enters Dark Cave:
- Check if lantern is in inventory. If not, game over.
When the player enters Treasure Chamber:
- Check if sword is in inventory. If yes, win. If no, lose.
When the player tries to go west from Rapid River:
- Check if raft is in inventory. If yes, move to Hidden Grotto. Else, can’t cross.
When in Dark Cave and trying to go north to Treasure Chamber:
- Check if the gate is unlocked (after using the key). If yes, proceed. Else, gate is locked.
But how to track if the gate is unlocked. Maybe a variable, like gate_unlocked = False. When the player uses the key in Dark Cave, set gate_unlocked to True.
So, variables for game state:
inventory = [ ]
current_room = ‘Mystical Forest’
gate_unlocked = False
game_over = False
Then, in the game loop:
while not game_over:
print description of current_room
show items available
get input
process command
Now, processing ‘use key’ in Dark Cave:
if current_room == ‘Dark Cave’ and ‘rusty key’ in inventory:
print(“You unlock the gate with the key.”)
gate_unlocked = True
inventory.remove(‘rusty key’)
Then, when trying to go north from Dark Cave:
if current_room == ‘Dark Cave’ and direction == ‘north’:
if gate_unlocked:
current_room = ‘Treasure Chamber’
else:
print(“The gate is locked.”)
Similarly, entering Dark Cave:
when the player moves to Dark Cave:
if current_room == ‘Dark Cave’:
if ‘lantern’ not in inventory:
print(“It’s too dark! You stumble and fall into a pit. Game Over!”)
game_over = True
But how to trigger this check when entering the room. Maybe after changing the current_room, check for any entry conditions.
So in the movement handling:
if direction is valid and room exists:
new_room = … get the new room based on direction
current_room = new_room
check entry conditions for new_room
For example:
if new_room == ‘Dark Cave’:
if ‘lantern’ not in inventory:
print(“… Game Over!”)
game_over = True
Similarly, when entering Treasure Chamber:
if new_room == ‘Treasure Chamber’:
if ‘sword’ in inventory:
print(“You defeat the dragon and claim the treasure! You win!”)
else:
print(“The dragon attacks! You are defeated. Game Over!”)
game_over = True
So the code would need to handle these entry actions.
Putting this all together in Python code.
Let’s draft the code step by step.
First, define the rooms and their properties.
rooms = {
‘Mystical Forest’: {
‘description’: ‘You are in a mystical forest. Tall trees tower above, their leaves filtering sunlight. Paths lead north, east, and west. A lantern lies on the ground.’,
‘items’: [‘lantern’],
‘exits’: {
‘north’: ‘Dark Cave’,
‘east’: ‘Enchanted Clearing’,
‘west’: ‘Rapid River’
}
},
‘Enchanted Clearing’: {
‘description’: ‘You enter a serene clearing. Sunlight bathes a stone pedestal holding a rusty key. The forest lies to the west.’,
‘items’: [‘rusty key’],
‘exits’: {
‘west’: ‘Mystical Forest’
}
},
‘Rapid River’: {
‘description’: ‘You stand before a raging river. The water rushes past violently. A small raft is moored to the shore here. Paths lead east and west.’,
‘items’: [‘raft’],
‘exits’: {
‘east’: ‘Mystical Forest’,
‘west’: ‘Hidden Grotto’
}
},
‘Hidden Grotto’: {
‘description’: ‘You find yourself in a hidden grotto behind the river. A gleaming sword is embedded in a stone.’,
‘items’: [‘sword’],
‘exits’: {
‘east’: ‘Rapid River’
}
},
‘Dark Cave’: {
‘description’: ‘You are at the mouth of a dark cave. Without a light, you cannot see inside.’,
‘items’: [ ],
‘exits’: {
‘south’: ‘Mystical Forest’,
‘north’: ‘Treasure Chamber’
}
},
‘Treasure Chamber’: {
‘description’: ‘A massive chamber filled with golden treasure! A ferocious dragon guards the hoard!’,
‘items’: [ ],
‘exits’: {}
}
}
Then, initialize variables.
inventory = [ ]
current_room = ‘Mystical Forest’
gate_unlocked = False
game_over = False
Now, the game loop.
print(“Welcome to Mystical Quest!”)
print(“Type commands like ‘go north’, ‘take lantern’, ‘use key’, ‘inventory’, ‘look’, ‘quit’.”)
while not game_over:
# Print current room description
print(“\n” + rooms[current_room][‘description’])
# List items in the room
if rooms[current_room][‘items’]:
print("You see: " + ", ".join(rooms[current_room][‘items’]))
else:
print(“There are no items here.”)
# Handle player input
command = input("\n> ").lower().strip()
if command.startswith('go '):
direction = command.split(’ ', 1)[1]
exits = rooms[current_room][‘exits’]
if direction in exits:
new_room = exits[direction]
# Check if the new room has entry conditions
if new_room == ‘Dark Cave’:
if ‘lantern’ not in inventory:
print(“\nIt’s pitch black! You stumble into a pit and perish. Game Over!”)
game_over = True
continue
else:
print(“\nYour lantern illuminates the cave. You see a locked gate to the north.”)
elif new_room == ‘Treasure Chamber’:
if current_room == ‘Dark Cave’ and not gate_unlocked:
print(“\nThe gate is locked. You need a key to open it.”)
continue
else:
# Handle entering Treasure Chamber
current_room = new_room
# Check for dragon confrontation
print(“\n” + rooms[current_room][‘description’])
if ‘sword’ in inventory:
print(“\nYou draw the sword and defeat the dragon! You claim the treasure! You win!”)
else:
print(“\nThe dragon breathes fire! You are burned to a crisp. Game Over!”)
game_over = True
continue
elif new_room == ‘Hidden Grotto’:
if current_room == ‘Rapid River’ and ‘raft’ in inventory:
current_room = new_room
else:
print(“\nThe river is too dangerous to cross without a raft!”)
continue
else:
current_room = new_room
else:
print(“\nYou can’t go that way!”)
elif command.startswith('take '):
item = command.split(’ ', 1)[1]
if item in rooms[current_room][‘items’]:
inventory.append(item)
rooms[current_room][‘items’].remove(item)
print(f"\nYou take the {item}.")
else:
print(“\nThat item isn’t here.”)
elif command.startswith('use '):
item = command.split(’ ', 1)[1]
if item not in inventory:
print(“\nYou don’t have that item.”)
else:
if current_room == ‘Dark Cave’ and item == ‘rusty key’:
print(“\nYou unlock the gate with the rusty key!”)
gate_unlocked = True
inventory.remove(item)
else:
print(“\nYou can’t use that here.”)
elif command == ‘inventory’:
if inventory:
print("\nInventory: " + ", ".join(inventory))
else:
print(“\nYour inventory is empty.”)
elif command == ‘look’:
print(“\n” + rooms[current_room][‘description’])
if rooms[current_room][‘items’]:
print("You see: " + ", ".join(rooms[current_room][‘items’]))
elif command == ‘quit’:
print(“\nThanks for playing!”)
game_over = True
else:
print(“\nI don’t understand that command.”)
This code handles movement, taking items, using the key in the Dark Cave, and checks for victory or defeat in the Treasure Chamber.
Testing the flow:
-
Player starts in Mystical Forest. Takes lantern.
-
Goes east to Enchanted Clearing. Takes key.
-
Goes west back to Forest.
-
Goes north to Dark Cave (has lantern). Now in Dark Cave.
-
Uses key to unlock gate.
-
Goes north to Treasure Chamber. If player has sword, wins. Else, loses.
To get sword:
-
From Forest, goes west to Rapid River. Takes raft.
-
Goes west to Hidden Grotto (needs raft). Takes sword.
-
Returns east to River, then east to Forest, north to Cave, uses key, north to Treasure Chamber. Wins.
This should work.
Potential issues:
-
In the code, when moving to Hidden Grotto from Rapid River, the code checks if ‘raft’ is in inventory. But the raft is taken from Rapid River, so the player must have it.
-
Using the key in Dark Cave removes it from inventory and unlocks the gate.
-
When entering Treasure Chamber, the code checks if ‘sword’ is in inventory and handles victory or defeat.
Possible missing features:
-
The raft isn’t consumed when used. The player can take it once and use it multiple times. That’s okay.
-
The ‘look’ command redisplays the room description and items.
-
The ‘inventory’ command shows current items.
Edge Cases Tested:
-
Trying to go to Dark Cave without lantern: game over.
-
Trying to unlock gate without key: message.
-
Trying to take an item not present: message.
-
Using an item in the wrong place: message.
This should cover the basic functionality.
(Due to technical issues, the search service is temporarily unavailable.)
Here’s a Zork-like text adventure game called Mystical Quest:
python Copy
# Mystical Quest - A Zork-like Text Adventure
rooms = {
'Mystical Forest': {
'description': 'You are in a mystical forest. Tall trees tower above, their leaves filtering sunlight. Paths lead north, east, and west. A lantern lies on the ground.',
'items': ['lantern'],
'exits': {'north': 'Dark Cave', 'east': 'Enchanted Clearing', 'west': 'Rapid River'}
},
'Enchanted Clearing': {
'description': 'You enter a serene clearing. Sunlight bathes a stone pedestal holding a rusty key. The forest lies to the west.',
'items': ['rusty key'],
'exits': {'west': 'Mystical Forest'}
},
'Rapid River': {
'description': 'You stand before a raging river. The water rushes past violently. A small raft is moored to the shore. Paths lead east and west.',
'items': ['raft'],
'exits': {'east': 'Mystical Forest', 'west': 'Hidden Grotto'}
},
'Hidden Grotto': {
'description': 'You find yourself in a hidden grotto behind the river. A gleaming sword is embedded in a stone.',
'items': ['sword'],
'exits': {'east': 'Rapid River'}
},
'Dark Cave': {
'description': 'You are at the mouth of a dark cave. Without a light, you cannot see inside.',
'items': [],
'exits': {'south': 'Mystical Forest', 'north': 'Treasure Chamber'}
},
'Treasure Chamber': {
'description': 'A massive chamber filled with golden treasure! A ferocious dragon guards the hoard!',
'items': [],
'exits': {}
}
}
inventory = []
current_room = 'Mystical Forest'
gate_unlocked = False
game_over = False
print("Welcome to Mystical Quest!")
print("Type commands like 'go north', 'take lantern', 'use key', 'inventory', 'look', or 'quit'.")
while not game_over:
print("\n" + rooms[current_room]['description'])
if rooms[current_room]['items']:
print("You see: " + ", ".join(rooms[current_room]['items']))
else:
print("There are no items here.")
command = input("\n> ").lower().strip()
if command.startswith('go '):
direction = command.split()[1]
exits = rooms[current_room]['exits']
if direction in exits:
new_room = exits[direction]
# Special room handling
if new_room == 'Dark Cave':
if 'lantern' not in inventory:
print("\nIt's pitch black! You stumble into a pit and perish. Game Over!")
game_over = True
continue
else:
print("\nYour lantern illuminates the cave. You see a locked gate to the north.")
if new_room == 'Treasure Chamber':
if current_room == 'Dark Cave' and not gate_unlocked:
print("\nThe gate is locked. You need a key to open it.")
continue
if new_room == 'Hidden Grotto':
if 'raft' not in inventory:
print("\nThe river is too dangerous to cross without a raft!")
continue
current_room = new_room
# Victory/Defeat conditions
if current_room == 'Treasure Chamber':
print("\n" + rooms[current_room]['description'])
if 'sword' in inventory:
print("\nYou draw the sword and defeat the dragon! You claim the treasure! You win!")
else:
print("\nThe dragon breathes fire! You are burned to a crisp. Game Over!")
game_over = True
else:
print("\nYou can't go that way!")
elif command.startswith('take '):
item = command.split()[1]
if item in rooms[current_room]['items']:
inventory.append(item)
rooms[current_room]['items'].remove(item)
print(f"\nYou take the {item}.")
else:
print("\nThat item isn't here.")
elif command.startswith('use '):
item = command.split()[1]
if item not in inventory:
print("\nYou don't have that item.")
elif current_room == 'Dark Cave' and item == 'rusty key':
print("\nYou unlock the gate with the rusty key!")
gate_unlocked = True
inventory.remove(item)
else:
print("\nYou can't use that here.")
elif command == 'inventory':
if inventory:
print("\nInventory: " + ", ".join(inventory))
else:
print("\nYour inventory is empty.")
elif command == 'look':
print("\n" + rooms[current_room]['description'])
if rooms[current_room]['items']:
print("You see: " + ", ".join(rooms[current_room]['items']))
elif command == 'quit':
print("\nThanks for playing!")
game_over = True
else:
print("\nI don't understand that command.")
How to Play:
Move using go [direction] (north, south, east, west)
Collect items with take [item]
Use items with use [item]
Check your inventory with inventory
Re-examine your surroundings with look
Quit with quit
Objective:
Find the treasure guarded by a dragon in the Treasure Chamber. You’ll need to:
Collect the lantern in the Mystical Forest
Get the rusty key from the Enchanted Clearing
Unlock the gate in the Dark Cave
Retrieve the sword from the Hidden Grotto (requires raft)
Defeat the dragon to win!
Can you solve the puzzles and survive the adventure?