feat: complete q1
This commit is contained in:
parent
91ef999a94
commit
f9da3043da
23
inference.py
23
inference.py
@ -18,7 +18,7 @@ from typing import List, Dict, Tuple
|
||||
import busters
|
||||
import game
|
||||
import bayesNet as bn
|
||||
from bayesNet import normalize
|
||||
from bayesNet import constructEmptyBayesNet, normalize
|
||||
import hunters
|
||||
from util import manhattanDistance, raiseNotDefined
|
||||
from factorOperations import joinFactorsByVariableWithCallTracking, joinFactors
|
||||
@ -61,7 +61,26 @@ def constructBayesNet(gameState: hunters.GameState):
|
||||
variableDomainsDict = {}
|
||||
|
||||
"*** YOUR CODE HERE ***"
|
||||
raiseNotDefined()
|
||||
# construct variables & edges
|
||||
variables = [PAC, GHOST0, GHOST1, OBS0, OBS1]
|
||||
edges = [(GHOST0, OBS0), (PAC, OBS0), (PAC, OBS1), (GHOST1, OBS1)] # reference: explantion figure from UCB CS188
|
||||
# https://inst.eecs.berkeley.edu/~cs188/sp24/assets/projects/busters_bayes_net_simplified.png
|
||||
# agent's possible position for variable domain
|
||||
possible_positions = []
|
||||
for x in range(X_RANGE):
|
||||
for y in range(Y_RANGE):
|
||||
possible_positions.append((x, y))
|
||||
variableDomainsDict[PAC] = possible_positions.copy()
|
||||
variableDomainsDict[GHOST0] = possible_positions.copy()
|
||||
variableDomainsDict[GHOST1] = possible_positions.copy()
|
||||
|
||||
# observation's variable domain
|
||||
# UCB CS188's problem explantion:
|
||||
# - Observations here are non-negative, equal to Manhattan distances of Pacman to ghosts ± noise
|
||||
max_observation = manhattanDistance((0, 0), (X_RANGE-1, Y_RANGE-1)) + MAX_NOISE
|
||||
variableDomainsDict[OBS0] = list(range(max_observation+1))
|
||||
variableDomainsDict[OBS1] = list(range(max_observation+1))
|
||||
|
||||
"*** END YOUR CODE HERE ***"
|
||||
|
||||
net = bn.constructEmptyBayesNet(variables, edges, variableDomainsDict)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user