feat: complete q6
This commit is contained in:
parent
37b07afc50
commit
cd9629462e
10
inference.py
10
inference.py
@ -202,7 +202,6 @@ def inferenceByVariableEliminationWithCallTracking(callTrackingList=None):
|
|||||||
|
|
||||||
"*** YOUR CODE HERE ***"
|
"*** YOUR CODE HERE ***"
|
||||||
current_factors = bayesNet.getAllCPTsWithEvidence(evidenceDict)
|
current_factors = bayesNet.getAllCPTsWithEvidence(evidenceDict)
|
||||||
print(joinFactorsByVariable)
|
|
||||||
|
|
||||||
for eliminate_var in eliminationOrder:
|
for eliminate_var in eliminationOrder:
|
||||||
unjoined_factors, joined_factor = joinFactorsByVariable(current_factors, eliminate_var)
|
unjoined_factors, joined_factor = joinFactorsByVariable(current_factors, eliminate_var)
|
||||||
@ -358,8 +357,6 @@ class DiscreteDistribution(dict):
|
|||||||
"""
|
"""
|
||||||
"*** YOUR CODE HERE ***"
|
"*** YOUR CODE HERE ***"
|
||||||
total = self.total()
|
total = self.total()
|
||||||
print("TOTAL:", total)
|
|
||||||
print(self)
|
|
||||||
if total != 0:
|
if total != 0:
|
||||||
for k, v in self.items():
|
for k, v in self.items():
|
||||||
self[k] = v/total
|
self[k] = v/total
|
||||||
@ -586,7 +583,12 @@ class ExactInference(InferenceModule):
|
|||||||
position is known.
|
position is known.
|
||||||
"""
|
"""
|
||||||
"*** YOUR CODE HERE ***"
|
"*** 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 ***"
|
"*** END YOUR CODE HERE ***"
|
||||||
self.beliefs.normalize()
|
self.beliefs.normalize()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user