Reflex Cleaning Agent

Reflex Cleaning Agent 


percept=["dirty","dirty"]
action=["Move Right","Move Left","Clean Dirt"]
class Agent:
    def __init__(self):
        self.position=0
        self.currentAction=0
        self.runAgent()
    def runAgent(self):
        self.getAction(percept[0])
    def getAction(self,cPercept):
        if(cPercept=="dirty"):
            self.currentAction=action[2]
            self.updateRooms()
        elif(cPercept=="clean"):
            if(self.position==0):
                self.currentAction=action[0]
                self.updatePosition()
            elif(self.position==1):
                self.currentAction=action[1]
                self.updatePosition()
    def updatePosition(self):
        if(self.currentAction==action[0]):
            self.position=1
            self.getAction(percept[1])
        elif(self.currentAction==action[1]):
            self.position=0
            
    def updateRooms(self):
        if(self.position==0):
            percept[0]="clean"
            self.runAgent()
        elif(self.position==1):
            percept[1]="clean"
        
        
V_agent=Agent()
print(percept)


Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........