diff --git a/inference.py b/inference.py index bdfb615..27cd213 100644 --- a/inference.py +++ b/inference.py @@ -202,7 +202,6 @@ def inferenceByVariableEliminationWithCallTracking(callTrackingList=None): "*** YOUR CODE HERE ***" current_factors = bayesNet.getAllCPTsWithEvidence(evidenceDict) - print(joinFactorsByVariable) for eliminate_var in eliminationOrder: unjoined_factors, joined_factor = joinFactorsByVariable(current_factors, eliminate_var) @@ -358,8 +357,6 @@ class DiscreteDistribution(dict): """ "*** YOUR CODE HERE ***" total = self.total() - print("TOTAL:", total) - print(self) if total != 0: for k, v in self.items(): self[k] = v/total @@ -586,7 +583,12 @@ class ExactInference(InferenceModule): position is known. """ "*** YOUR CODE HERE ***" - raiseNotDefined() + pacman_position = gameState.getPacmanPosition() + jail_position = self.getJailPosition() + + for ghost_position in self.allPositions: + prob = self.getObservationProb(observation, pacman_position, ghost_position, jail_position) + self.beliefs[ghost_position] *= prob "*** END YOUR CODE HERE ***" self.beliefs.normalize()