The Hidden Warehouse Game
Concept:
A text-based adventure game where the player navigates a mysterious warehouse grid to find a hidden exit while avoiding traps. The warehouse is a 10x10 grid with rooms of three types: Safe (S), Trap (T), and Exit (E). The player starts at a random safe room and must reach the exit without running out of health.
Game Mechanics:
-
Grid Setup:
- 10x10 grid with randomly placed rooms:
- Safe (S): 60% of rooms (60 rooms).
- Trap (T): 20% of rooms (20 rooms).
- Exit (E): 1 room (guaranteed not to be the starting position).
- Player starts at a random safe room.
- 10x10 grid with randomly placed rooms:
-
Player Stats:
- Health: Starts at 3. Decreases by 1 for each trap encountered.
- Game Over: Health reaches 0.
-
Movement:
- Directions:
n(North),s(South),e(East),w(West). - Invalid moves are blocked.
- Directions:
-
Room Interactions:
- Safe (S): No effect.
- Trap (T): Health decreases by 1. Player is teleported to a random safe room.
- Exit (E): Win the game.
-
Goal: Find the exit while managing health.
Python Implementation
import random
def create_grid():
"""Generate a 10x10 grid with Safe, Trap, and Exit rooms."""
grid = [['S' for _ in range(10)] for _ in range(10)]
# Place 20 traps
trap_count = 0
while trap_count < 20:
row = random.randint(0, 9)
col = random.randint(0, 9)
if grid[row][col] == 'S':
grid[row][col] = 'T'
trap_count += 1
# Place exit (avoid starting position)
while True:
row = random.randint(0, 9)
col = random.randint(0, 9)
if grid[row][col] == 'S':
grid[row][col] = 'E'
break
return grid
def get_safe_rooms(grid):
"""List all safe rooms (S) excluding the exit."""
safe_rooms = []
for i in range(10):
for j in range(10):
if grid[i][j] == 'S':
safe_rooms.append((i, j))
return safe_rooms
def display_status(health, row, col):
"""Print current game status."""
print(f"\nHealth: {health}")
print(f"Position: ({row}, {col})")
def play_game():
"""Main game loop."""
grid = create_grid()
safe_rooms = get_safe_rooms(grid)
# Set starting position (random safe room)
start_row, start_col = random.choice(safe_rooms)
health = 3
print("Welcome to the Hidden Warehouse!")
print("Find the exit (E) while avoiding traps (T).")
print("Move: n (North), s (South), e (East), w (West)")
while True:
display_status(health, start_row, start_col)
room = grid[start_row][start_col]
# Check room type
if room == 'E':
print("\nYou found the exit! You win!")
break
elif room == 'T':
health -= 1
print("\nYou stepped on a trap! Health reduced by 1.")
if health <= 0:
print("Game Over! You ran out of health.")
break
else:
# Teleport to a random safe room
start_row, start_col = random.choice(safe_rooms)
print(f"Teleported to a safe room at ({start_row}, {start_col}).")
continue
# Get player input
move = input("Enter your move (n/s/e/w): ").lower()
# Calculate new position
new_row, new_col = start_row, start_col
if move == 'n':
new_row = max(0, start_row - 1)
elif move == 's':
new_row = min(9, start_row + 1)
elif move == 'e':
new_col = min(9, start_col + 1)
elif move == 'w':
new_col = max(0, start_col - 1)
else:
print("Invalid move! Use n, s, e, or w.")
continue
# Update position if moved
if (new_row, new_col) != (start_row, start_col):
start_row, start_col = new_row, new_col
if __name__ == "__main__":
play_game()
How to Play:
- Run the script.
- You start at a random safe room (S) with 3 health.
- Enter movement commands (
n,s,e,w) to navigate. - Trap (T): Lose 1 health and teleport to a new safe room.
- Exit (E): Win the game!
- Health reaches 0: Game over.
Example Gameplay:
Welcome to the Hidden Warehouse!
Find the exit (E) while avoiding traps (T).
Move: n (North), s (South), e (East), w (West)
Health: 3
Position: (5, 5)
Enter your move (n/s/e/w): n
Health: 3
Position: (4, 5)
Enter your move (n/s/e/w): e
Health: 3
Position: (4, 6)
Enter your move (n/s/e/w): s
Health: 2
Position: (5, 6)
You stepped on a trap! Health reduced by 1.
Teleported to a safe room at (2, 3).
Health: 2
Position: (2, 3)
Enter your move (n/s/e/w): e
...
Key Features:
- Dynamic Grid: Each game has a random layout.
- Health Management: Balance risk vs. reward when exploring.
- Teleportation: Trap encounters force relocation, adding unpredictability.
- Simple Controls: Intuitive movement commands.
Enjoy exploring the Hidden Warehouse! 🏭🔍
Request an On-site Audit / Inquiry