Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Random Game in Python? I came up with the following and the notes at the very bottom are the instructions. Please help me modify the

Random Game in Python?

I came up with the following and the notes at the very bottom are the instructions. Please help me modify the code to get a code in which I was instructed.

import random

# create variable for player score (as zero) player_score = 0

# create variable for score needed to win ; random score to win win_score = 100

# Set of points for player points = [-3,-2,-1,1,2,3,4,5,6,7,8,9,10]

# complete location list locations = ["brooklyn", "queens", "long island", "staten island", "manhattan"]

# Indicating that player did not win the game won = False

# game loop (until the player has won the game)

while not won: # A random point from the set of points is selected current_point = random.randint(-3, 10) # A random location from the set of locations current_location = random.choice(list(locations.keys())) # Printing current location that is being explored by the player print("The player is currently exploring: " + str(current_location)) # If location has hazard then decrease the player one point from current point if locations[current_location] == "hazard": player_score += current_point

INSTRUCTIONS:

  • Imagine the player is exploring a location, whether it's an old castle or a hidden cave. As they explore different spots within the location, they may find treasure (gain points) or encounter some hazard (lose points)

  • Complete the list of locations with text strings that represent different spots in the location the player is exploring

  • Assume the player starts at 0 points. Decide what will be a winning score. The player will move through the location until they gain enough points to reach the winning score.

  • Each turn through the while loop, print the value of a random choice from the locations list.

  • Get a random integer for points from this room. Allow the possibility to get a negative value. So for example, between -3 and 10 as possible random integers.

  • Add (or subtract) that random number to the player score.

  • Once the player has won, print a winning message and their final score.

  • There is no need for user input in this game. The computer is making random choices for the player.

print the random location the player is moving to get a random number of points for this room add (or subtract) that number of points to player score

once player has won, print winning message and final score

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

Step: 3

blur-text-image

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

which of the following is not true of cross - functional teams?

Answered: 1 week ago

Question

What is the use of bootstrap program?

Answered: 1 week ago

Question

What is a process and process table?

Answered: 1 week ago

Question

What is Industrial Economics and Theory of Firm?

Answered: 1 week ago