def initialize(self): """ Initialize the agent's beliefs to a prior sampling over positions. """ "*** YOUR CODE HERE ***" self.particles = util.sampleMultiple(self.game.getInitialDistribution(), self.numParticles)
def initialize(self): """ Initialize the agent's beliefs to a prior sampling over positions. """ "*** YOUR CODE HERE ***" self.particles = util.sampleMultiple( self.game.getInitialDistribution(), self.numParticles)
def observe(self, observation, emissionFn): # update beliefs # P(X_t | e_1:t, e') ~ P(e'|X_t) * P(X_t | e_1:t) for particle in self.particles.keys(): # reweight each particle by observations self.particles[particle] *= emissionFn(observation, particle) # resample observation self.particles.normalize() samples = util.sampleMultiple(self.particles, self.numParticles) self.particles = util.listToDistribution(samples)
def observe(self, observation): """ Update beliefs to reflect the given observations. Observation will require that you resample from your particles, where each particle is weighted by the observation's likelihood given the state represented by that particle. """ "*** YOUR CODE HERE ***" weight = util.Counter() for particle in self.particles: weight[particle] = self.game.getReadingDistributionGivenGhostTuple( particle, observation[0]).getCount(observation[1]) weight.normalize() if weight.totalCount() == 0: self.initialize() else: self.particles = util.sampleMultiple(weight, self.numParticles)
def observe(self, observation): """ Update beliefs to reflect the given observations. Observation will require that you resample from your particles, where each particle is weighted by the observation's likelihood given the state represented by that particle. """ "*** YOUR CODE HERE ***" weight = util.Counter() for particle in self.particles: weight[particle] = self.game.getReadingDistributionGivenGhostTuple(particle, observation[0]).getCount( observation[1] ) weight.normalize() if weight.totalCount() == 0: self.initialize() else: self.particles = util.sampleMultiple(weight, self.numParticles)