1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
uysha [10]
1 year ago
5

How do you fix this?

Engineering
1 answer:
NeX [460]1 year ago
3 0

Using the knowledge in computational language in python it is possible to write a code that was fixed;

<h3>Writting in python:</h3>

<em>from random import randint</em>

<em>class Character:</em>

<em>    def __init__(self):</em>

<em>        self.name = ""</em>

<em>        self.health = 1</em>

<em>        self.health_max = 1</em>

<em>    def do_damage(self, enemy):</em>

<em>        damage = min(</em>

<em>            max(randint(0, self.health) - randint(0, enemy.health), 0),</em>

<em>            enemy.health)</em>

<em>        enemy.health = enemy.health - damage</em>

<em>        if damage == 0:</em>

<em>            print("%s evades %s's attack." % (enemy.name, self.name))</em>

<em>        else:</em>

<em>            print("%s hurts %s!" % (self.name, enemy.name))</em>

<em>        return enemy.health <= 0</em>

<em>class Enemy(Character):</em>

<em>    def __init__(self, player):</em>

<em>        Character.__init__(self)</em>

<em>        self.name = 'a goblin'</em>

<em>        self.health = randint(1, player.health)</em>

<em>class Player(Character):</em>

<em>    def __init__(self):</em>

<em>        Character.__init__(self)</em>

<em>        self.state = 'normal'</em>

<em>        self.health = 10</em>

<em>        self.health_max = 10</em>

<em>    def quit(self):</em>

<em>        print(</em>

<em>            "%s can't find the way back home, and dies of starvation.\nR.I.P." % self.name)</em>

<em>        self.health = 0</em>

<em>    def help(self): print(Commands.keys())</em>

<em>    def status(self): print("%s's health: %d/%d" %</em>

<em>                            (self.name, self.health, self.health_max))</em>

<em>    def tired(self):</em>

<em>        print("%s feels tired." % self.name)</em>

<em>        self.health = max(1, self.health - 1)</em>

<em>    def rest(self):</em>

<em>        if self.state != 'normal':</em>

<em>            print("%s can't rest now!" % self.name)</em>

<em>            self.enemy_attacks()</em>

<em>        else:</em>

<em>            print("%s rests." % self.name)</em>

<em>            if randint(0, 1):</em>

<em>                self.enemy = Enemy(self)</em>

<em>                print("%s is rudely awakened by %s!" %</em>

<em>                      (self.name, self.enemy.name))</em>

<em>                self.state = 'fight'</em>

<em>                self.enemy_attacks()</em>

<em>            else:</em>

<em>                if self.health < self.health_max:</em>

<em>                    self.health = self.health + 1</em>

<em>                else:</em>

<em>                    print("%s slept too much." % self.name)</em>

<em>                    self.health = self.health - 1</em>

<em>    def explore(self):</em>

<em>        if self.state != 'normal':</em>

<em>            print("%s is too busy right now!" % self.name)</em>

<em>            self.enemy_attacks()</em>

<em>        else:</em>

<em>            print("%s explores a twisty passage." % self.name)</em>

<em>            if randint(0, 1):</em>

<em>                self.enemy = Enemy(self)</em>

<em>                print("%s encounters %s!" % (self.name, self.enemy.name))</em>

<em>                self.state = 'fight'</em>

<em>            else:</em>

<em>                if randint(0, 1):</em>

<em>                    self.tired()</em>

<em>    def flee(self):</em>

<em>        if self.state != 'fight':</em>

<em>            print("%s runs in circles for a while." % self.name)</em>

<em>            self.tired()</em>

<em>        else:</em>

<em>            if randint(1, self.health + 5) > randint(1, self.enemy.health):</em>

<em>                print("%s flees from %s." % (self.name, self.enemy.name))</em>

<em>                self.enemy = None</em>

<em>                self.state = 'normal'</em>

<em>            else:</em>

<em>                print("%s couldn't escape from %s!" %</em>

<em>                      (self.name, self.enemy.name))</em>

<em>                self.enemy_attacks()</em>

<em>    def attack(self):</em>

<em>        if self.state != 'fight':</em>

<em>            print("%s swats the air, without notable results." % self.name)</em>

<em>            self.tired()</em>

<em>        else:</em>

<em>            if self.do_damage(self.enemy):</em>

<em>                print("%s executes %s!" % (self.name, self.enemy.name))</em>

<em>                self.enemy = None</em>

<em>                self.state = 'normal'</em>

<em>                if randint(0, self.health) < 10:</em>

<em>                    self.health = self.health + 1</em>

<em>                    self.health_max = self.health_max + 1</em>

<em>                    print("%s feels stronger!" % self.name)</em>

<em>            else:</em>

<em>                self.enemy_attacks()</em>

<em>    def enemy_attacks(self):</em>

<em>        if self.enemy.do_damage(self):</em>

<em>            print("%s was slaughtered by %s!!!\nR.I.P." %</em>

<em>                  (self.name, self.enemy.name))</em>

<em>Commands = {</em>

<em>    'quit': Player.quit,</em>

<em>    'help': Player.help,</em>

<em>    'status': Player.status,</em>

<em>    'rest': Player.rest,</em>

<em>    'explore': Player.explore,</em>

<em>    'flee': Player.flee,</em>

<em>    'attack': Player.attack,</em>

<em>}</em>

<em>p = Player()</em>

<em>p.name = input("What is your character's name? ")</em>

<em>print("(type help to get a list of actions)\n")</em>

<em>print("%s enters a dark cave, searching for adventure." % p.name)</em>

<em>while(p.health > 0):</em>

<em>    line = input("> ")</em>

<em>    args = line.split()</em>

<em>    if len(args) > 0:</em>

<em>        commandFound = False</em>

<em>        for c in Commands.keys():</em>

<em>            if args[0] == c[:len(args[0])]:</em>

<em>                Commands[c](p)</em>

<em>                commandFound = True</em>

<em>                break</em>

<em>        if not commandFound:</em>

<em>            print("%s doesn't understand the suggestion." % p.name)</em>

See more about python at brainly.com/question/12975450

#SPJ1

You might be interested in
Sawing stock to reduce its thickness is known as __________ .
rjkz [21]

Answer:

resawing

Explanation:

8 0
4 years ago
On Canvas you will find a dataset titled CPS2015, which contains data for full-time, full-year workers, ages 25–34, with a high
Anna71 [15]

In this question, we are missing the data that is necessary to fully answer it. However, we can still talk about the relationship that you will be studying in order to help you analyze the results that you will obtain.

It is true that older people tend to make more money than younger people. According to PayScale, wages increase 30% for men and 34% for females between the ages of 22 and 30. Moreover, full time workers with bachelor degrees do not reach their peak in income until their 40s (women) or 50s (men).

8 0
4 years ago
Calculate the resistance of a lamp if the current through it is 0.4 A and the voltage across it is 8 V.
Papessa [141]

Answer:

Answer is 3.2 Ω (Ohms)

Explanation:

From Ohms Law I = V/R

R = V(I)

R = 8(0.4)

R = 3.2

6 0
3 years ago
Annie has collected several items from around her house. She is using these objects to investigate which objects are attracted t
Margarita [4]
The metal screw would be attracted to her magnet since its metal and the others don’t attract to magnets.
5 0
4 years ago
Three piezometers located 1000 m apart bottom in the same horizontal aquifer. Piezometer A is due south of piezometer B and piez
leva [86]

Answer:

Hydraulic gradient=0.0173

Explanation:

The hydraulic head at the points A, B and C will be as follows

A=95-5=90 m

B=110-30=80 m

C=135-35= 100 m

By drawing the equipotential lines, the direction of ground water can be seen as in the triangle

The length of flow will be

L=\sqrt {1000^{2}-500^{2}}\approx 866.025 m

The hydraulic gradient will be given by

i=\frac {\triangle h}{L}=\frac {95-80}{866.025}\approx 0.0173

3 0
3 years ago
Other questions:
  • Modulus of resilience is: (a) Slope of elastic portion of stress- strain curve (b) Area under the elastic portion of the stress-
    12·1 answer
  • Twenty distinct cars park in the same parking lot every day. Ten of these cars are US-made, while the other ten are foreign-made
    5·1 answer
  • Please help me in this assignment.
    13·1 answer
  • Three parallel three-phase loads are supplied from a 480V (line-line RMS), 60 Hz three-phase supply. The loads are as follows: L
    5·1 answer
  • Describe what you have been taught about the relationship between basic science research, and technological innovation before th
    8·1 answer
  • <img src="https://tex.z-dn.net/?f=2x%20-%2014x%20%3D%2010" id="TexFormula1" title="2x - 14x = 10" alt="2x - 14x = 10" align="abs
    14·2 answers
  • 8. What is the density of an object with a mass of 290.5 g and volume of 83 cm 3?​
    13·1 answer
  • Taking the convection heat transfer coefficient on both sides of the plate to be 860 W/m2 ·K, deter- mine the temperature of the
    10·1 answer
  • I need the answer please
    7·1 answer
  • What were the trade-offs and opportunity costs of one of Teasha’s economic decisions?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!