Question: Help I dont know what am doing wrong, this is my failed attempted:# BEGIN Problem 7# The HungryAnt Classclass HungryAnt(Ant): name = 'Hungry' food_cost =

Help I dont know what am doing wrong, this is my failed attempted:# BEGIN Problem 7# The HungryAnt Classclass HungryAnt(Ant): name = 'Hungry' food_cost = 4 implemented = True chewing_turns = 3 damage = 0 def __init__(self,health=1): super().__init__(health) self.turns_to_chew = 0 def action(self,gamestate): if self.turns_to_chew == 0: if len(self.place.bees) > 0: target_bee = random_bee(self.place.bee) target_bee.reduce_health(target_bee.health) self.turns_to_chew = self.chewing_turns else: self.turns_to_chew -=1# END Problem 7

Problem 7 (3 pt) Implement the HungryAnt, which will select a random

Problem 7 (3 pt) Implement the HungryAnt , which will select a random Bee from its place and deal damage to the Bee by eating it whole. After eating a Bee, a HungryAnt must spend 3 turns chewing before being able to eat again. While the HungryAnt is chewing, it is not able to eat (deal damage to) any Bee s. After 3 turns, if there is no bee available to eat, the HungryAnt will do nothing. We have not provided you with a class header. Implement the HungryAnt class from scratch. Give it a class attribute name with the value 'Hungry' (so that the graphics work) and a class attribute implemented with the value True (so that you can use it in a game). Hint: When a Bee is eaten, it should lose all its health. Is there an existing function we can call on a Bee that can reduce its health to 0? m Food Cost Initial Health Give HungryAnt a chewing7turns class attribute that stores the number of turns that it will take a HungryAnt to chew (set to 3). Also, give each HungryAnt an instance attribute turns_to_chew that counts the number of turns it has left to chew (initialized to 0, since it hasn't eaten anything at the beginning. You can also think of turns,to,chew as the number of turns until a HungryAnt can eat another Bee). Implement the action method of the HungryAnt : First, check if it is chewing; if so, decrement its turnsitoichew. Otherwise, eat a random Bee in its place by reducing the Bee's health to 0. Make sure to set the turns_to_chew when a Bee is eaten! Hint Other than the action method, make sure you implement the "init method too in order to define any instance variables and make sure that HungryAnt starts off with the appropriate amount of health

Problem 7 (3 pt) Implement the HungryAnt, which will select a random Bee from its place and deal damage to the Bee by eating it whole. After eating a Bee, a HungryAnt must spend 3 turns chewing before being able to eat again. While the HungryAnt is chewing, it is not able to eat (deal damage to) any Bee s. After 3 turns, if there is no bee available to eat, the HungryAnt will do nothing. We have not provided you with a class header. Implement the HungryAnt class from scratch. Give it a class attribute name with the value 'Hungry (so that the graphics work) and a class attribute implemented with the value True (so that you can use it in a game). Hint: When a Bee is eaten, it should lose all its health. Is there an existing function we can call on a Bee that can reduce its health to 0? Class HungryAnt Food Cost 4 Initial Health 1 Give HungryAnt a chewing_turns class attribute that stores the number of turns that it will take a HungryAnt to chew (set to 3). Also, give each HungryAnt an instance attribute turns_to_chew that counts the number of turns it has left to chew (initialized to 0, since it hasn't eaten anything at the beginning. You can also think of turns_to_chew as the number of turns until a HungryAnt can eat another Bee ). Implement the action method of the Hungry Ant : First, check if it is chewing; if so, decrement its turns_to_chew. Otherwise, eat a random Bee in its place by reducing the Bee 's health to 0. Make sure to set the turns_to_chew when a Bee is eaten! Hint: Other than the action method, make sure you implement the ___init__ method too in order to define any instance variables and make sure that HungryAnt starts off with the appropriate amount of health!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

PROGRAM APPROACH Define a class HungryAnt inheriting from Ant Set class attributes name as Hungry an... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!