Write code in Python for Blind Dog Agent: Create an agent blind-dog who can only feel what's in his location (since he's blind) and can eat or drink. The blind-dog is hungry and needs to search for food. But before that, let's create an environment for the blind-dog to play in. The blind-dog can perceive and act upon the environment. The environment contains some food, water, and the blind-dog The Blind-Dog to be able to randomly move down and eat food or drink water only if it is present. The bling-dog first eat the food and then drink the water after eating the food
Write code in Python for Blind Dog Agent:
Create an agent blind-dog who can only feel what's in his location (since he's blind) and can eat or drink.
The blind-dog is hungry and needs to search for food. But before that, let's create an environment for the blind-dog to play in. The blind-dog can perceive and act upon the environment. The environment contains some food, water, and the blind-dog
The Blind-Dog to be able to randomly move down and eat food or drink water only if it is present.
The bling-dog first eat the food and then drink the water after eating the food.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Change the following case in a way that it randomly moves down and eat/drink something only if it's present. Give the output screenshot
import random
#Dog Class
class Dog:
#constructor
def __init__(self, name):
self.name = name
def eat(self):
print("{} is eating.".format(self.name))
def drink(self):
print("{} is drinking.".format(self.name))
# The Blind-Dog class inherits from the Dog class
class BlindDog(Dog):
def __init__(self, name, hunger=0, thirst=0):
super().__init__(name)
self.hunger = hunger
self.thirst = thirst
# The Blind-Dog can only feel what's in his location
def feel(self, environment):
if environment == "food":
return True
elif environment == "water":
return True
else:
return False
# The Blind-Dog is hungry and needs to search for food
def search_for_food(self):
if self.feel("food"):
print("I found food!")
self.eat()
else:
print("There is no food around.")
# The Blind-Dog is thirsty and needs to search for water
def search_for_water(self):
if self.feel("water"):
print("I found water!")
self.drink()
else:
print("There is no water around.")
# The Blind-Dog first eat the food and then drink the water after eating the food
def eat_and_drink(self):
self.search_for_food()
self.search_for_water()
def main():
# Create an environment for the blind-dog to play in
environment = ["food", "water"]
# Create an instance of the Blind-Dog class
dog = BlindDog("Bingo", 0, 0)
# The blind-dog can perceive and act upon the environment
dog.eat_and_drink()
if __name__ == "__main__":
main()
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)