feat: complete q6

This commit is contained in:
snsd0805 2024-05-07 20:46:15 +08:00
parent 37b07afc50
commit cd9629462e
Signed by: snsd0805
GPG Key ID: 569349933C77A854

View File

@ -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()