예제 #1
0
 def __init__(self, x=60, y=60, orientation=0, linear=1, angular=0, agent_color='r'):
     self.state = State(x, y, orientation, linear, angular)
     self.map = Map()
     self.pixels_per_meter = 20  # TODO: Make mutator or include in constructor
     self.type = agent_color
     self.sensor = Sensor()
     self.controller = Controller()
     self.sensor_noise = NormalDistribution()
     self.actuator_noise = NormalDistribution()
예제 #2
0
class Agent(object):
    def __init__(self, x=60, y=60, orientation=0, linear=1, angular=0, agent_color='r'):
        self.state = State(x, y, orientation, linear, angular)
        self.map = Map()
        self.pixels_per_meter = 20  # TODO: Make mutator or include in constructor
        self.type = agent_color
        self.sensor = Sensor()
        self.controller = Controller()
        self.sensor_noise = NormalDistribution()
        self.actuator_noise = NormalDistribution()

    def update(self):
        perception = self.sensor.read(self.state)
        noise = np.random.normal(self.sensor_noise.mean,self.sensor_noise.variance,len(perception))
        self.controller.setPerception( perception + noise )

        noise = np.random.normal(self.actuator_noise.mean,self.actuator_noise.variance,2)
        (self.state.velocity.linear,self.state.velocity.angular) = self.controller.getAction() + noise