@author: Sahil
“”"
import random
class room(object):
def init(self):
self.locondt = {‘A’:‘0’,‘B’:‘0’}
self.locondt[‘A’] = random.randint(0, 1)
self.locondt[‘B’] = random.randint(0, 1)
class VacuumAgent(room):
def init (self,room):
print(room.locondt)
place=0
vacuumlocation = random.randint(0,1)
if vacuumlocation == 0:
print(“Vacuum Cleaner is randomly placed at room A.”)
if room.locondt[‘A’]==1:
print(“Room A is dirty.”)
if room.locondt[‘A’]== 0:
place +=1
print(“Room A has been cleaned”)
print(“Now moving to room B”)
place -=1
if room.locondt[‘B’] ==1:
print(“Room B is dirty.”)
if room.locondt[‘B’] ==0:
place +=1
print(“Room B has been cleaned.”)
else:
place -=1
print(“Now moving to room B”)
if room.locondt['B'] == 1:
print("Room B is dirty.")
if room.locondt['B'] ==0:
place +=1
print("Room B has been cleaned.")
elif vacuumlocation == 1:
print("Vacuum Cleaner is randomly placed at room B.")
if room.locondt['B'] == 1:
print("Room B is dirty.")
room.locondt['B'] = 0;
place += 1
print("Room B has been Cleaned.")
place -= 1
print("Now moving to room A.")
if room.locondt['A'] == 1:
print("Room A is Dirty.")
room.locondt['A'] = 0;
place += 1
print("Room A has been Cleaned.")
else:
print("Now moving to room B")
place -= 1
if room.locondt['A'] == 1:
print("Room A is dirty.")
if room.locondt['A'] == 0:
place += 1
print("Room A has been Cleaned.")
print(room.locondt)
print("Performance Measurement: " + str(place))
theroom = room()
thevacuum = VacuumAgent()