Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple Escape Room text game using python Question 4 (20 points] You have just started your new job as a puzzle engineer at Sierra Studios.

Simple Escape Room text game using python image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Question 4 (20 points] You have just started your new job as a puzzle engineer at Sierra Studios. Your first task is to create a simple escape the room type game in the Python programming language. An escape the room' game is defined as follows. When the program runs a description of a room with no exits will be given to the user listing objects and people in the room). The user will then be given a chance to type in a command to interact with the objects and/or people in some way (e. examine the table' or 'talk to Bob'). Interacting in this manner will give responses containing hints as to how to escape the room. For example, after examining the table and talking with Bob, the user might discover they have to flip the lightswitch in order for a secret door to open. Then, if the user enters 'flip the lightswitch', they will win and the game will be over. Your escape room implementation must contain at least the following elements: A function escape room that returns True only when the player has escaped the room sue cessfully. (E..., in the above example, True would be returned if the user enters the phrase "flip the lightswitch.) The function should start by printing a description of the room, including the objects you can examine and people you can talk to. Commands should be stored in a dictionary, with each key being a command and each value being the message to print when that command is entered Inside a loop, the user should be asked to enter a command, and then the corresponding message in the dictionary should be printed. If the command is not present in the dictionary "Invalid command." should be printed. The command should be turned into lowercase, so if the user uses capitals in an otherwise valid command, the command will still work. . Two special commands, not stored in the dictionary, should also be available for the ser. One is the command commands, which should display to the user all commands present in the dictionary. The other command will be the special command that lets the user escape the room (ex. flip the light switch' in the example above). This command should print a message like 'You have found the secret door!' and then return True. Try to make this command ensy to guess, or allow multiple ways for the user to express it (e.g., 'enter in keypad might also be expressed as 'press 0' or 'enter 0' or 'press key 0'). There should be at least one object in the room for the user to examine, and when the user types examine (object), a hint should be given about how to escape the room. This object should be listed in the description. Note that it does not have to be an object, but at minimum something that can be examined (eg, texture of the walls of the room, rug on the floor, etc). There should be at least one named person in the room for the user to talk to, and when the user types talk to person, a hint should be given about how to escape the room. This person should be listed in the description. Note that it does not have to be a person, but minimally something that can give and/or receive input (eg, computer, intercom, keypad, etc). At the top of your code file, give your escape room a name by defining the ROOM. NAME variable, and write your name in the AUTHOR variable. These will have no use for your code, but we will use them in grading.) Any submission meeting these requirements will get full marks, but you are encouraged to go beyond them, either in terms of creativity of descriptions, complexity of puzzles, or technical sophistication The most impressive submissions (as judged by our TAS) will be shown in class and/or stitched together into a combined work. Filename You must write this program in a file called dungeon.py. Some code is already provided to you Examples (as executed in Thonny) EXAMPLE 1: You find yourself in a dark room. A candle lies on a small table in front of - you, providing a small amount of light. You cannot see any door or exit. However, there is what seems to be a keypad on one of the walls. > EXAMINE CANDLE The candle is tall and thin. You decide to pick it up to examine the rest of - the room more closely. You think you can make out half of a mathematical equation on the walls: e to the power i times pi... > examine keypad It is a standard keypad, with digits from 0-9. Looking closely, you think you can make out half of a mathematical equation scratched into the wall above > smash keypad Invalid command > Commands Commands are: examine candle, examine keypad enter O in keypad A secret door opens ! EXAMPLE 2: You have walked deep into a cave, looking for treasure, when suddenly you wander down a dead-end and hear the tumble of rocks from behind you. You are trapped! In front of you, the rock face is smooth and glistening with moisture. Moss of many different hues grows on the surface. There is an - eerie silence, punctuated only by the drops of water from the ceiling into - a small pond next to you. What do you do? > Cesands examine moss examine pond > examine moss You examine the moss closely. Most of the moss are hues of green, but there is - one very small area where it is bright purple. You suddenly realize this - purple moss is displayed in the shape of a key hole. Perhape if you had a - key, you could use it here. > examine pond You kneel down and peer into the pond. In the reflection of the water, you see yourself with a key in your hand. Your reflection then smiles and puts the - key in your pocket. Startled, you stand up and feel inside your pocket - there is a key there! If only you knew where to use it. put key in keyhole A secret door opens in the rock wall! AUTHOR = "your name here" ROOM_NAME = "name of your escape room here" def escape_room(): print("You find yourself in a dark room") commands = { # insert key-value pairs here while True: cmd = input(" ") # turn command to lowercase # print appropriate message # check if command is one of the 2 special commands # return True if user has entered correct answer # Calling the function so that it runs when we run the file. escape_room()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

Students also viewed these Databases questions