Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python question: Winning the game! Run Terminal Save Mark Problem Solutions program.py> room = 1 end False while not end: Now we are going to
Python question:
Winning the game! Run Terminal Save Mark Problem Solutions program.py> room = 1 end False while not end: Now we are going to expand on our code that tracks which room the player is in so that the game ends when the player gets to the "end" room. This is our win condition and all good games have one of those! This time, to help you along a bit, we're going to give you two code snippets. The first you'll recognise from the last question it changes which room you are in if you are in the "middle" room: if room"middle": if room1: print("Actions available: forward, look") cmdinput("> ") if cmd look' print ("You are standing at the entrance to a long tunnel.") elif cmdforward' print("Actions available: forward, backward, look") action input(" ") if action"forward": room = 2 elif room 2: if not end: print("You are in the depths of the tunnel.") print("Actions available: forward, backward, look") cmdinput("> ") if cmd Look' elif cmdforward' room "end" elif action "backward" room "start" else: room 3: elif cmd'backward' room "middle" The other hint we will give you is a combination of some variables you will need to track the player's progress, and a clue about the overall structure of the program: # initialise the game room "start" Submissions Output Autosaved #14 Testing the first example in the question. Testing the second example in the question. Your submission did not produce the correct output. Your program Load Not yet! Failed a test (1 test passed). a month ago Load V # Loop while the player is not in the end room X # Check what room the player is in # Give the correct action options # Updates the room variable # Give feedback based on the room they are in output: Actions available: forward, look > look You are standing at the entrance to a long tunnel. Actions available: forward, Look forward Hint
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started